Skip to content

Commit

Permalink
It is impossible to change a default value of the ChoicesRestful.path…
Browse files Browse the repository at this point in the history
… property fix #6766 (#6827)
  • Loading branch information
andrewtelnov authored Aug 30, 2023
1 parent 1045344 commit f27e327
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export class Base {
if (this.isPropertyEmpty(res)) {
const locStr = this.localizableStrings ? this.localizableStrings[name] : undefined;
if(locStr) return locStr.text;
if (defaultValue != null) return defaultValue;
if (defaultValue !== null && defaultValue !== undefined) return defaultValue;
const propDefaultValue = this.getDefaultPropertyValue(name);
if(propDefaultValue !== undefined) return propDefaultValue;
}
Expand Down
3 changes: 2 additions & 1 deletion src/choicesRestful.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ export class ChoicesRestful extends Base {
*/

public get path(): string {
return this.getPropertyValue("path", "");
const res = this.getPropertyValue("path");
return !!res ? res : "";
}
public set path(val: string) {
this.setPropertyValue("path", val);
Expand Down
7 changes: 7 additions & 0 deletions tests/question_baseselecttests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1204,4 +1204,11 @@ QUnit.test("Use carryForward with panel dynamic + update data on survey.data=dat
assert.equal(q2.visibleChoices[1].value, 2, "the second value is correct");
assert.equal(q2.visibleChoices[1].text, "Item 2", "the second text is correct");
});
QUnit.test("Allow to override default value fro choicesByUrl.path Bug#6766", function (assert) {
const prop = Serializer.findProperty("choicesByUrl", "path");
prop.defaultValue = "list";
const q1 = new QuestionDropdownModel("q1");
assert.equal(q1.choicesByUrl.path, "list", "get new default value for path");
prop.defaultValue = undefined;
});

0 comments on commit f27e327

Please sign in to comment.