Skip to content

Commit

Permalink
Multiple Text: Rename itemSize to inputSize fix #5137 (#9231)
Browse files Browse the repository at this point in the history
* Multiple Text: Rename itemSize to inputSize fix #5137

* Add a deprecation message

---------

Co-authored-by: RomanTsukanov <[email protected]>
  • Loading branch information
andrewtelnov and RomanTsukanov authored Jan 7, 2025
1 parent e71d7cf commit 26e7c0e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
20 changes: 13 additions & 7 deletions packages/survey-core/src/question_multipletext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export class MultipleTextItemModel extends Base
/**
* A value passed on to the [`size`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/size) attribute of the underlying `<input>` element.
*
* If you want to set a uniform `size` for all text box items, use the [`itemSize`](https://surveyjs.io/form-library/documentation/api-reference/multiple-text-entry-question-model#itemSize) within the Multiple Textboxes configuration.
* If you want to set a uniform `size` for all text box items, use the [`inputSize`](https://surveyjs.io/form-library/documentation/api-reference/multiple-text-entry-question-model#inputSize) within the Multiple Textboxes configuration.
*/
public get size(): number {
return this.editor.size;
Expand Down Expand Up @@ -433,7 +433,7 @@ export class QuestionMultipleTextModel extends Question
this.registerPropertyChangedHandlers(["items", "colCount", "itemErrorLocation"], () => {
this.calcVisibleRows();
});
this.registerPropertyChangedHandlers(["itemSize"], () => { this.updateItemsSize(); });
this.registerPropertyChangedHandlers(["inputSize"], () => { this.updateItemsSize(); });
}
public getType(): string {
return "multipletext";
Expand Down Expand Up @@ -620,12 +620,18 @@ export class QuestionMultipleTextModel extends Question
/**
* A value passed on to the [`size`](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/size) attribute of the underlying `<input>` elements.
*/
public get itemSize(): number {
return this.getPropertyValue("itemSize");
public get inputSize(): number {
return this.getPropertyValue("inputSize");
}
public set itemSize(val: number) {
this.setPropertyValue("itemSize", val);
public set inputSize(val: number) {
this.setPropertyValue("inputSize", val);
}
/**
* Obsolete. Use the [`inputSize`](https://surveyjs.io/form-library/documentation/api-reference/multiple-text-entry-question-model#inputSize) property instead.
* @deprecated
*/
public get itemSize(): number { return this.inputSize; }
public set itemSize(val: number) { this.inputSize = val; }
/**
* Specifies a uniform width for all text box titles. Accepts CSS values.
*
Expand Down Expand Up @@ -993,7 +999,7 @@ Serializer.addClass(
"multipletext",
[
{ name: "!items:textitems", className: "multipletextitem", isArray: true },
{ name: "itemSize:number", minValue: 0, visible: false },
{ name: "inputSize:number", minValue: 0, visible: false, alternativeName: "itemSize" },
{ name: "colCount:number", default: 1, choices: [1, 2, 3, 4, 5] },
{ name: "itemErrorLocation", default: "default", choices: ["default", "top", "bottom"], visible: false },
{ name: "itemTitleWidth", category: "layout" }
Expand Down
4 changes: 2 additions & 2 deletions packages/survey-core/src/question_text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ export class QuestionTextModel extends QuestionTextBase {
this.isTextInput &&
size < 1 &&
this.parent &&
!!(<any>this.parent)["itemSize"]
!!(<any>this.parent)["inputSize"]
) {
size = (<any>this.parent)["itemSize"];
size = (<any>this.parent)["inputSize"];
}
this.setPropertyValue("inputSize", size);
this.setPropertyValue("inputWidth", size > 0 ? "auto" : "");
Expand Down
4 changes: 2 additions & 2 deletions packages/survey-core/tests/question_multipletexttests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ QUnit.test("defaultValueExpression executing", (assert) => {
q1.items[1].value = 5;
assert.equal(q1.items[2].editor.value, 15, "Calculated correctly");
});
QUnit.test("Make itemSize invisible by default", (assert) => {
const prop = Serializer.findProperty("multipletext", "itemSize");
QUnit.test("Make inputSize invisible by default", (assert) => {
const prop = Serializer.findProperty("multipletext", "inputSize");
assert.strictEqual(prop.visible, false);
});
2 changes: 1 addition & 1 deletion packages/survey-core/tests/surveyquestiontests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5433,7 +5433,7 @@ QUnit.test("text question inputSize and inputWidth", function (assert) {
assert.equal(q2.inputStyle.width, "", "q2 inputStyle width is undefined");
assert.equal(q3.inputStyle.width, "", "q3 inputStyle width is undefined");
});
QUnit.test("Multiple Text Question: itemSize", function (assert) {
QUnit.test("Multiple Text Question: inputSize", function (assert) {
var mText = new QuestionMultipleTextModel("mText");
mText.items.push(new MultipleTextItemModel("q1"));
mText.items.push(new MultipleTextItemModel("q2"));
Expand Down

0 comments on commit 26e7c0e

Please sign in to comment.