Skip to content

Commit d40fff6

Browse files
authored
fix(ui5-multi-combobox): clear value state error on item selection (#13404)
* fix(ui5-multi-combobox): clear value state error on item selection fixes: #13385
1 parent b43f56e commit d40fff6

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

packages/main/cypress/specs/MultiComboBox.cy.tsx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,6 +1953,53 @@ describe("Validation & Value State", () => {
19531953
.find(".ui5-valuestatemessage--warning")
19541954
.should("not.exist");
19551955
});
1956+
1957+
it("Value state resets when selecting an item after invalid input", () => {
1958+
cy.mount(
1959+
<MultiComboBox>
1960+
<MultiComboBoxItem text="Item 1"></MultiComboBoxItem>
1961+
<MultiComboBoxItem text="Item 2"></MultiComboBoxItem>
1962+
</MultiComboBox>
1963+
);
1964+
1965+
cy.get("[ui5-multi-combobox]")
1966+
.as("mcb")
1967+
.realClick();
1968+
1969+
cy.get("@mcb")
1970+
.should("be.focused");
1971+
1972+
cy.realType("xyz");
1973+
1974+
cy.get("@mcb")
1975+
.should("have.attr", "value-state", "Negative");
1976+
1977+
cy.get("@mcb")
1978+
.shadow()
1979+
.find("input")
1980+
.clear();
1981+
1982+
cy.realType("Item");
1983+
1984+
cy.get("@mcb")
1985+
.shadow()
1986+
.find<ResponsivePopover>("ui5-responsive-popover")
1987+
.ui5ResponsivePopoverOpened();
1988+
1989+
cy.get("@mcb")
1990+
.find("[ui5-mcb-item]")
1991+
.eq(0)
1992+
.realClick();
1993+
1994+
cy.get("@mcb")
1995+
.should("have.attr", "value-state", "None");
1996+
1997+
cy.get("@mcb")
1998+
.shadow()
1999+
.find("[ui5-tokenizer]")
2000+
.find("[ui5-token]")
2001+
.should("have.length", 1);
2002+
});
19562003
});
19572004

19582005
describe("Keyboard interaction when pressing Ctrl + Alt + F8 for navigation", () => {

packages/main/src/MultiComboBox.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,10 @@ class MultiComboBox extends UI5Element implements IFormInputElement {
16481648
this.filterSelected = false;
16491649
}
16501650

1651+
if (this.valueState === ValueState.Negative) {
1652+
this._updateValueState(this._effectiveValueState);
1653+
}
1654+
16511655
if (!e.detail.selectionComponentPressed && !isSpace(castedEvent) && !isSpaceCtrl(castedEvent)) {
16521656
this.open = false;
16531657
this.value = "";

0 commit comments

Comments
 (0)