Skip to content

Commit 8664743

Browse files
fix(ui5-multi-input): fire change event on enter (#12516)
1 parent 38a5049 commit 8664743

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,24 @@ describe("Keyboard handling", () => {
13351335
cy.get("[ui5-multi-input]")
13361336
.should("have.attr", "value-state", "None");
13371337
});
1338+
1339+
it("should trigger change event on enter with no suggestions", () => {
1340+
const changeSpy = cy.stub().as("changeSpy");
1341+
cy.mount(
1342+
<MultiInput onChange={changeSpy}></MultiInput>
1343+
);
1344+
1345+
cy.get("[ui5-multi-input]")
1346+
.shadow()
1347+
.find("input")
1348+
.realClick();
1349+
1350+
cy.realType("asd");
1351+
cy.realPress("Enter");
1352+
1353+
cy.get("@changeSpy")
1354+
.should("have.been.calledOnce");
1355+
});
13381356
});
13391357

13401358
describe("MultiInput Composition", () => {
@@ -1371,7 +1389,7 @@ describe("MultiInput Composition", () => {
13711389
cy.get("@multiinput").should("have.prop", "_isComposing", true);
13721390

13731391
cy.get("@nativeInput").trigger("compositionend", { data: "사랑" });
1374-
1392+
13751393
cy.get("@nativeInput")
13761394
.invoke("val", "사랑")
13771395
.trigger("input", { inputType: "insertCompositionText" });
@@ -1425,7 +1443,7 @@ describe("MultiInput Composition", () => {
14251443
cy.get("@multiinput").should("have.prop", "_isComposing", true);
14261444

14271445
cy.get("@nativeInput").trigger("compositionend", { data: "ありがとう" });
1428-
1446+
14291447
cy.get("@nativeInput")
14301448
.invoke("val", "ありがとう")
14311449
.trigger("input", { inputType: "insertCompositionText" });
@@ -1479,7 +1497,7 @@ describe("MultiInput Composition", () => {
14791497
cy.get("@multiinput").should("have.prop", "_isComposing", true);
14801498

14811499
cy.get("@nativeInput").trigger("compositionend", { data: "谢谢" });
1482-
1500+
14831501
cy.get("@nativeInput")
14841502
.invoke("val", "谢谢")
14851503
.trigger("input", { inputType: "insertCompositionText" });

packages/main/src/MultiInput.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class MultiInput extends Input implements IFormInputElement {
233233
return this._focusFirstToken(e);
234234
}
235235

236-
if (isEnter(e)) {
236+
if (isEnter(e) && !!this._internals.form) {
237237
e.preventDefault();
238238
}
239239

0 commit comments

Comments
 (0)