Skip to content

Commit

Permalink
Property locale string value reset isn't working for non-default locale
Browse files Browse the repository at this point in the history
fix #7388
  • Loading branch information
andrewtelnov committed Nov 21, 2023
1 parent f89e1ec commit 6634f33
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ export class Base {
public resetPropertyValue(name: string): void {
const locStr = this.localizableStrings ? this.localizableStrings[name] : undefined;
if(locStr) {
locStr.clearLocale();
locStr.clear();
}
else {
this.setPropertyValue(name, undefined);
Expand Down
14 changes: 14 additions & 0 deletions tests/basetests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { SurveyModel } from "../src/survey";
import { Action } from "../src/actions/action";
import { findParentByClassNames } from "../src/utils/utils";
import { QuestionDropdownModel } from "../src/question_dropdown";
export * from "../src/localization/german";

export default QUnit.module("Base");

Expand Down Expand Up @@ -776,4 +777,17 @@ QUnit.test("base.resetPropertyValue() for localization string", function (assert
const prop = Serializer.findProperty("survey", "completeText");
prop.setValue(survey, "", null);
assert.equal(survey.completeText, "", "Empty string after prop.setValue func");
});
QUnit.test("base.resetPropertyValue() for localization string, #2, bug#7388", function (assert) {
const survey = new SurveyModel();
assert.equal(survey.completeText, "Complete", "default value");
survey.completeText = "test en";
assert.equal(survey.completeText, "test en", "set value en");
survey.locale = "de";
survey.completeText = "test de";
assert.equal(survey.completeText, "test de", "set value de");
survey.resetPropertyValue("completeText");
assert.equal(survey.completeText, "Abschließen", "default value de");
survey.locale = "";
assert.equal(survey.completeText, "Complete", "default value en");
});

0 comments on commit 6634f33

Please sign in to comment.