Skip to content

Commit

Permalink
MaxSelectedChoices stop updating Disabled class for selectbase (probl…
Browse files Browse the repository at this point in the history
…em with v1.9.139) fix #8159
  • Loading branch information
andrewtelnov committed Apr 22, 2024
1 parent e73aa35 commit f91462c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/question_baseselect.ts
Expand Up @@ -1723,7 +1723,7 @@ export class QuestionSelectBase extends Question {
options.isNone = isNone;

return builder
.append(this.cssClasses.itemDisabled, this.isDisabledStyle)
.append(this.cssClasses.itemDisabled, isDisabled || this.isDisabledStyle)
.append(this.cssClasses.itemReadOnly, this.isReadOnlyStyle)
.append(this.cssClasses.itemPreview, this.isPreviewStyle)
.append(this.cssClasses.itemChecked, isChecked)
Expand Down
23 changes: 23 additions & 0 deletions tests/question_baseselecttests.ts
Expand Up @@ -315,6 +315,29 @@ QUnit.test("check allowhover class in design mode", (assert) => {
survey.setDesignMode(true);
assert.ok(q1.getItemClass(item).indexOf("sv_q_checkbox_hover") == -1);
});
QUnit.test("maxSelectedChoices & getItemClass, bug#8159", (assert) => {
var json = {
questions: [
{
type: "checkbox",
name: "q1",
choices: ["Item1", "Item2", "Item3"],
maxSelectedChoices: 2
},
],
};
const survey = new SurveyModel(json);
const q1 = <QuestionSelectBase>survey.getQuestionByName("q1");
const disableStyle = "sv_q_disable";
q1.cssClasses.itemDisabled = disableStyle;
q1.renderedValue = ["Item1", "Item3"];
assert.ok(q1.visibleChoices[0].enabled, "Item1 enabled #2");
assert.notOk(q1.getItemClass(q1.visibleChoices[0]).indexOf(disableStyle) >= 0, "Item1 #1");
assert.notOk(q1.visibleChoices[1].enabled, "Item2 enabled #2");
assert.ok(q1.getItemClass(q1.visibleChoices[1]).indexOf(disableStyle) >= 0, "Item2 #2");
assert.notOk(q1.getItemClass(q1.visibleChoices[2]).indexOf(disableStyle) >= 0, "Item3 #3");
});

QUnit.test("check item value type", (assert) => {
const survey = new SurveyModel({
questions: [
Expand Down

0 comments on commit f91462c

Please sign in to comment.