Skip to content

Commit

Permalink
Work for #5686: refactor + fix vrt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dk981234 committed Mar 20, 2023
1 parent f516cce commit d22bd58
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/defaultV2-theme/blocks/sd-element.scss
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
line-height: calcSize(2);
color: $foreground-light;
margin-inline-start: calcSize(-5); // margin-left
text-align: right;
text-align: end;
box-sizing: border-box;
white-space: nowrap;
flex-shrink: 0;
Expand Down
11 changes: 1 addition & 10 deletions src/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1932,16 +1932,7 @@ export class PanelModel extends PanelModelBase implements IElement {
this.survey.cancelPreviewByPage(this);
}
public get cssTitle(): string {
const isExpandable = this.state !== "default";
return new CssClassBuilder()
.append(this.cssClasses.panel.title)
.append(this.cssClasses.panel.titleNumInline, (this.no || "").length > 3 || isExpandable)
.append(this.cssClasses.panel.titleExpandable, isExpandable)
.append(this.cssClasses.panel.titleExpanded, this.isExpanded)
.append(this.cssClasses.panel.titleCollapsed, this.isCollapsed)
.append(this.cssClasses.panel.titleDisabled, this.isReadOnly)
.append(this.cssClasses.panel.titleOnError, this.containsErrors)
.toString();
return this.getCssTitle(this.cssClasses.panel);
}
public get cssError(): string {
return this.getCssError(this.cssClasses);
Expand Down
9 changes: 1 addition & 8 deletions src/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -798,15 +798,8 @@ export class Question extends SurveyElement<Question>
this.setPropertyValue("cssTitle", val);
}
protected getCssTitle(cssClasses: any): string {
const isExpandable = this.state !== "default";
return new CssClassBuilder()
.append(cssClasses.title)
.append(cssClasses.titleNumInline, (this.no || "").length > 3 || isExpandable)
.append(cssClasses.titleExpandable, isExpandable)
.append(cssClasses.titleExpanded, this.isExpanded)
.append(cssClasses.titleCollapsed, this.isCollapsed)
.append(cssClasses.titleDisabled, this.isReadOnly)
.append(cssClasses.titleOnError, this.containsErrors)
.append(super.getCssTitle(cssClasses))
.append(cssClasses.titleOnAnswer, !this.containsErrors && this.isAnswered)
.toString();
}
Expand Down
13 changes: 13 additions & 0 deletions src/survey-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Helpers } from "./helpers";
import { settings } from "./settings";
import { ILocalizableOwner, LocalizableString } from "./localizablestring";
import { ActionContainer, defaultActionBarCss } from "./actions/container";
import { CssClassBuilder } from "./utils/cssClassBuilder";
/**
* A base class for the [`SurveyElement`](https://surveyjs.io/form-library/documentation/surveyelement) and [`SurveyModel`](https://surveyjs.io/form-library/documentation/surveymodel) classes.
*/
Expand Down Expand Up @@ -900,6 +901,18 @@ export class SurveyElement<E = any> extends SurveyElementCore implements ISurvey
this.toggleState();
}
}
protected getCssTitle(cssClasses: any) {
const isExpandable = this.state !== "default";
const numInlineLimit = 4;
return new CssClassBuilder()
.append(cssClasses.title)
.append(cssClasses.titleNumInline, ((<any>this).no || "").length > numInlineLimit || isExpandable)
.append(cssClasses.titleExpandable, isExpandable)
.append(cssClasses.titleExpanded, this.isExpanded)
.append(cssClasses.titleCollapsed, this.isCollapsed)
.append(cssClasses.titleDisabled, this.isReadOnly)
.append(cssClasses.titleOnError, this.containsErrors).toString();
}
public localeChanged() {
super.localeChanged();
this.updateDescriptionVisibility(this.description);
Expand Down

0 comments on commit d22bd58

Please sign in to comment.