diff --git a/packages/survey-creator-core/src/components/item-value.ts b/packages/survey-creator-core/src/components/item-value.ts index 5d21e9026a..4baeb9de59 100644 --- a/packages/survey-creator-core/src/components/item-value.ts +++ b/packages/survey-creator-core/src/components/item-value.ts @@ -247,7 +247,7 @@ export class ItemValueWrapperViewModel extends Base { if(!Helpers.isNumber(val)) return false; const min = this.question.choicesMin; const max = this.question.choicesMax; - if(!Helpers.isNumber(min) || !Helpers.isNumber(max)) return false; + if(!Helpers.isNumber(min) || !Helpers.isNumber(max) || min === max && min === 0) return false; return val >= min && val <= max; } } diff --git a/packages/survey-creator-core/tests/components.tests.ts b/packages/survey-creator-core/tests/components.tests.ts index 511dc94a0b..61d9140454 100644 --- a/packages/survey-creator-core/tests/components.tests.ts +++ b/packages/survey-creator-core/tests/components.tests.ts @@ -150,6 +150,32 @@ test("Allow remove for choices and generated choices", () => { expect(generatedItemAdorner.allowAdd).toBeFalsy(); expect(generatedItemAdorner.allowRemove).toBeFalsy(); }); +test("Allow remove for choices with value equals to 0, Bug#5500", () => { + const creator = new CreatorTester(); + creator.JSON = { + elements: [{ type: "dropdown", name: "q1", choices: [0, 1, 2] }] + }; + const question = creator.survey.getAllQuestions()[0]; + + const choiceItem1Adorner = new ItemValueWrapperViewModel(creator, question, question.choices[0]); + const choiceItem2Adorner = new ItemValueWrapperViewModel(creator, question, question.choices[1]); + const choiceItem3Adorner = new ItemValueWrapperViewModel(creator, question, question.choices[2]); + expect(choiceItem1Adorner.item.value).toBe(0); + expect(choiceItem1Adorner.isNew).toBeFalsy(); + expect(choiceItem1Adorner.allowAdd).toBeFalsy(); + expect(choiceItem1Adorner.allowRemove).toBeTruthy(); + + expect(choiceItem2Adorner.item.value).toBe(1); + expect(choiceItem2Adorner.isNew).toBeFalsy(); + expect(choiceItem2Adorner.allowAdd).toBeFalsy(); + expect(choiceItem2Adorner.allowRemove).toBeTruthy(); + + expect(choiceItem3Adorner.item.value).toBe(2); + expect(choiceItem3Adorner.isNew).toBeFalsy(); + expect(choiceItem3Adorner.allowAdd).toBeFalsy(); + expect(choiceItem3Adorner.allowRemove).toBeTruthy(); + +}); test("item value allowRemove on events", () => { const creator = new CreatorTester();