Skip to content

Commit 1def053

Browse files
committed
fix(ui5-multi-input, ui5-combobox): focus input on VH icon press
1 parent 1500ada commit 1def053

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,17 @@ describe("General Interaction", () => {
176176
cy.get("[ui5-combobox]").should("have.prop", "focused", true);
177177
});
178178

179+
it("keeps focused state when clicking on the arrow icon", () => {
180+
cy.mount(
181+
<ComboBox>
182+
<ComboBoxItem text="One" />
183+
</ComboBox>
184+
);
185+
186+
cy.get("[ui5-combobox]").shadow().find("[ui5-icon]").realMouseDown();
187+
cy.get("[ui5-combobox]").should("have.prop", "focused", true);
188+
});
189+
179190
it("tests Combo with two-column layout", () => {
180191
cy.mount(
181192
<ComboBox>

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,30 @@ describe("MultiInput Web Component", () => {
243243
cy.get("@valueHelpTrigger")
244244
.should("have.been.calledTwice");
245245
});
246+
247+
it("keeps focused state when clicking on value help icon", () => {
248+
cy.mount(
249+
<MultiInput showValueHelpIcon={true}>
250+
<Token slot="tokens" text="Amet"></Token>
251+
</MultiInput>
252+
);
253+
254+
cy.get("[ui5-multi-input]")
255+
.as("multiInput");
256+
257+
cy.get("@multiInput")
258+
.shadow()
259+
.find(".ui5-input-inner")
260+
.as("innerInput");
261+
262+
cy.get("@multiInput")
263+
.shadow()
264+
.find("[ui5-icon]")
265+
.realMouseDown();
266+
267+
cy.get("@multiInput")
268+
.should("have.prop", "focused", true);
269+
});
246270
})
247271

248272
describe("MultiInput tokens", () => {

packages/main/src/ComboBox.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,8 +740,12 @@ class ComboBox extends UI5Element implements IFormInputElement {
740740
});
741741
}
742742

743-
_arrowClick() {
743+
_arrowMouseDown(e: MouseEvent) {
744+
e.preventDefault();
744745
this.inner.focus();
746+
}
747+
748+
_arrowClick() {
745749
this._resetFilter();
746750

747751
if (isPhone() && this.value && !this._lastValue) {

packages/main/src/MultiInput.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import type Token from "./Token.js";
3232
import type Tokenizer from "./Tokenizer.js";
3333
import { getTokensCountText } from "./Tokenizer.js";
3434
import type { TokenizerTokenDeleteEventDetail } from "./Tokenizer.js";
35-
import type Icon from "./Icon.js";
3635

3736
import type {
3837
InputSelectionChangeEventDetail as MultiInputSelectionChangeEventDetail,
@@ -215,11 +214,11 @@ class MultiInput extends Input implements IFormInputElement {
215214
}
216215

217216
valueHelpMouseDown(e: MouseEvent) {
218-
const target = e.target as Icon;
217+
e.preventDefault();
218+
this.focus();
219219
this.closeValueStatePopover();
220220
this.tokenizer.open = false;
221221
this._valueHelpIconPressed = true;
222-
target.focus();
223222
}
224223

225224
_tokenizerFocusOut(e: FocusEvent) {

0 commit comments

Comments
 (0)