From d77e5664c8acfb1abd93bf0145478065fcd623ac Mon Sep 17 00:00:00 2001 From: rhenck <richard.henck@iqb.hu-berlin.de> Date: Mon, 6 Dec 2021 14:56:52 +0100 Subject: [PATCH] Set default line height for likert and text It is okay to discard a 0 value here, as 0 line height makes no sense and it is better to use the default. --- projects/common/ui-elements/likert/likert-element.ts | 5 +++++ projects/common/ui-elements/text/text-element.ts | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/projects/common/ui-elements/likert/likert-element.ts b/projects/common/ui-elements/likert/likert-element.ts index 940e50450..1facc2b22 100644 --- a/projects/common/ui-elements/likert/likert-element.ts +++ b/projects/common/ui-elements/likert/likert-element.ts @@ -44,6 +44,11 @@ export class LikertElement extends CompoundElement implements PositionedElement, } else { this.positionProps.marginBottom = 30; } + // it is okay to discard a 0 value here, as 0 line height makes no sense and it is better to use the default. + this.fontProps.lineHeight = + serializedElement.fontProps?.lineHeight as number || + serializedElement.lineHeight as number || + 135; this.surfaceProps.backgroundColor = (serializedElement as unknown as SurfaceElement).surfaceProps?.backgroundColor as string || serializedElement.backgroundColor as string || diff --git a/projects/common/ui-elements/text/text-element.ts b/projects/common/ui-elements/text/text-element.ts index dd9798d5b..1d4ab6208 100644 --- a/projects/common/ui-elements/text/text-element.ts +++ b/projects/common/ui-elements/text/text-element.ts @@ -26,6 +26,12 @@ export class TextElement extends UIElement implements PositionedElement, FontEle this.surfaceProps = initSurfaceElement(serializedElement); this.height = serializedElement.height || 98; + // it is okay to discard a 0 value here, as 0 line height makes no sense and it is better to use the default. + this.fontProps.lineHeight = + serializedElement.fontProps?.lineHeight as number || + serializedElement.lineHeight as number || + 135; + this.surfaceProps.backgroundColor = serializedElement.surfaceProps?.backgroundColor as string || serializedElement.backgroundColor as string || -- GitLab