Skip to content

Commit

Permalink
Merge branch 'master' into bug/8209-a11y-readonly-2
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-kurmanov committed May 24, 2024
2 parents e8530fd + 6b96a96 commit bd2896b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2818,8 +2818,7 @@ Serializer.addClass("question", [
visibleIf: function (obj: any) {
return obj.showCommentArea;
},
serializationProperty: "locCommentText",
layout: "row",
serializationProperty: "locCommentText"
},
{
name: "commentPlaceholder",
Expand Down
6 changes: 5 additions & 1 deletion src/question_baseselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1040,8 +1040,12 @@ export class QuestionSelectBase extends Question {
if (!this.newItemValue) {
this.newItemValue = this.createItemValue("newitem"); //TODO
this.newItemValue.isGhost = true;
this.newItemValue.registerFunctionOnPropertyValueChanged("isVisible", () => {
this.updateVisibleChoices();
});
}
if (!this.isUsingCarryForward && this.canShowOptionItem(this.newItemValue, isAddAll, false)) {
if (this.newItemValue.isVisible && !this.isUsingCarryForward
&& this.canShowOptionItem(this.newItemValue, isAddAll, false)) {
this.footItemsCount = 1;
items.push(this.newItemValue);
}
Expand Down
18 changes: 9 additions & 9 deletions tests/localizablestringtests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,42 +729,42 @@ QUnit.test("Get/set language dialect", function (assert) {
locString.setJson({
default: "Default",
en: "English",
"en-UK": "English UK",
"en-GB": "English GB",
pt: "Portuguese"
});
assert.equal(locString.renderedHtml, "Default", "default locale");
owner.locale = "en";
assert.equal(locString.renderedHtml, "English", "en locale");
owner.locale = "en-UK";
assert.equal(locString.renderedHtml, "English UK", "en-UK locale");
owner.locale = "en-GB";
assert.equal(locString.renderedHtml, "English GB", "en-GB locale");
owner.locale = "pt";
assert.equal(locString.renderedHtml, "Portuguese", "pt locale");
owner.locale = "pt-BR";
assert.equal(locString.renderedHtml, "Portuguese", "pt-BR locale");
locString.text = "Portuguese BR";
owner.locale = "en-UK";
owner.locale = "en-GB";
locString.text = "English";
assert.deepEqual(locString.getJson(), {
default: "Default",
en: "English",
pt: "Portuguese",
"pt-BR": "Portuguese BR"
}, "Remove en-UK");
}, "Remove en-GB");
owner.locale = "en";
locString.text = "Default";
assert.deepEqual(locString.getJson(), {
default: "Default",
pt: "Portuguese",
"pt-BR": "Portuguese BR"
}, "Remove en");
owner.locale = "en-UK";
locString.text = "English UK";
owner.locale = "en-GB";
locString.text = "English GB";
assert.deepEqual(locString.getJson(), {
default: "Default",
"en-UK": "English UK",
"en-GB": "English GB",
pt: "Portuguese",
"pt-BR": "Portuguese BR"
}, "Add en-UK");
}, "Add en-GB");
});
QUnit.test("Do not reset values in any locale", function (assert) {
settings.storeDuplicatedTranslations = true;
Expand Down
16 changes: 16 additions & 0 deletions tests/question_baseselecttests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1318,6 +1318,22 @@ QUnit.test("Do not notify survey on changing newItem.value", function (
assert.equal(counter, 2, "Do not react on newItem properties changes, #4");
settings.supportCreatorV2 = false;
});
QUnit.test("Remove newItem from the list if it is false", function (
assert
) {
settings.supportCreatorV2 = true;
const survey = new SurveyModel();
survey.setDesignMode(true);
survey.fromJSON({
elements: [{ type: "checkbox", name: "q", choices: [1] }]
});
const q = <QuestionCheckboxModel>survey.getQuestionByName("q");
assert.equal(q.visibleChoices.length, 1 + 4, "#1");
q.newItem.setIsVisible(false);
assert.equal(q.visibleChoices.length, 1 + 3, "#2");
q.newItem.setIsVisible(true);
assert.equal(q.visibleChoices.length, 1 + 4, "#3");
});
QUnit.test("displayValue & otherItem", function (assert) {
const survey = new SurveyModel({
elements: [
Expand Down

0 comments on commit bd2896b

Please sign in to comment.