Skip to content

Commit

Permalink
resolve #8555 questionTitleWidth property - add 'px' to numeric values (
Browse files Browse the repository at this point in the history
#8566)

Co-authored-by: OlgaLarina <[email protected]>
  • Loading branch information
OlgaLarina and OlgaLarina authored Jul 16, 2024
1 parent b3c5ec7 commit aa269da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,11 @@ export class Question extends SurveyElement<Question>
}
public get titleWidth(): string {
if (this.getTitleLocation() === "left") {
if (!!this.parent) return this.parent.getQuestionTitleWidth();
if (!!this.parent) {
let width = this.parent.getQuestionTitleWidth() as any;
if (width && !isNaN(width)) width = width + "px";
return width;
}
}
return undefined;
}
Expand Down
3 changes: 3 additions & 0 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6984,6 +6984,9 @@ QUnit.test("Define questionTitleWidth on Panel/Page level", function (assert) {
panel2.questionTitleWidth = "200px";
assert.equal(q.titleWidth, "200px", "get from panel2");

panel2.questionTitleWidth = "300";
assert.equal(q.titleWidth, "300px", "titleWidth with px");

q.titleLocation = "top";
assert.equal(q.titleWidth, undefined, "titleWidth available if titleLocation is left");
});
Expand Down

0 comments on commit aa269da

Please sign in to comment.