Skip to content

Commit

Permalink
fix(ui5-combobox) always focus the next/previous element on TAB/SHIFT…
Browse files Browse the repository at this point in the history
…+TAB (#4218)

* Fix TAB handling when picker is opened

* Add additional check

* Fix test asserts
  • Loading branch information
ndeshev authored Nov 4, 2021
1 parent f2b5f64 commit 00c308f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/main/src/ComboBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
isDown,
isEnter,
isEscape,
isTabNext,
isTabPrevious,
} from "@ui5/webcomponents-base/dist/Keys.js";
import * as Filters from "./ComboBoxFilters.js";

Expand Down Expand Up @@ -724,6 +726,10 @@ class ComboBox extends UI5Element {
this._isValueStateFocused = false;
}

if ((isTabNext(event) || isTabPrevious(event)) && this.open) {
this._closeRespPopover();
}

if (isShow(event) && !this.readonly && !this.disabled) {
event.preventDefault();

Expand Down
20 changes: 20 additions & 0 deletions packages/main/test/specs/ComboBox.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -728,4 +728,24 @@ describe("Keyboard navigation", async () => {

assert.strictEqual(await prevListItem.getProperty("focused"), false, "The previously focused item is no longer focused");
});

it ("Should focus the next/previous focusable element on TAB/SHIFT+TAB", async () => {
await browser.url(`http://localhost:${PORT}/test-resources/pages/ComboBox.html`);

const combo = await browser.$("#combo-grouping");
const arrow = await combo.shadow$("[input-icon]");

const prevCombo = await browser.$("#value-state-grouping");
const nextCombo = await browser.$("#combobox-two-column-layout");

await arrow.click();
await combo.keys("Tab");

assert.strictEqual(await nextCombo.getProperty("focused"), true, "The next combobox should be focused");

await arrow.click();
await browser.keys(["Shift", "Tab"]);

assert.strictEqual(await prevCombo.getProperty("focused"), true, "The previous combobox should be focused");
});
});

0 comments on commit 00c308f

Please sign in to comment.