Skip to content

Commit 32a4148

Browse files
authored
fix(ui5-list): focus after element when TAB key is pressed (#3220)
If the "More" growing button is currently focused and the TAB key is pressed, focus is returning to the last focused ui5-li in the same list (focus trap). The focus is now moved to the next interactive element after the ui5-list, when TAB key is pressed.
1 parent 267fc02 commit 32a4148

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

packages/main/src/List.js

+5
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,11 @@ class List extends UI5Element {
666666
this._onLoadMoreClick();
667667
this._loadMoreActive = true;
668668
}
669+
670+
if (isTabNext(event)) {
671+
this.setPreviouslyFocusedItem(event.target);
672+
this.focusAfterElement();
673+
}
669674
}
670675

671676
_onLoadMoreKeyup(event) {

packages/main/test/pages/List_test_page.html

+8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@
3939

4040
<br><br><br>
4141

42+
<ui5-list id="growingListButton" growing="Button" style="height: 300px;">
43+
<ui5-li>Javascript</ui5-li>
44+
<ui5-li>PHP</ui5-li>
45+
</ui5-list>
46+
47+
<button id="nextInteractiveElement">Next Interactive element</button>
48+
49+
<br><br><br>
4250

4351
<br/>
4452
<ui5-list id="listEvents" mode="SingleSelectEnd">

packages/main/test/specs/List.spec.js

+10
Original file line numberDiff line numberDiff line change
@@ -354,4 +354,14 @@ describe("List Tests", () => {
354354

355355
assert.strictEqual(item3.getProperty("focused"), true, "disabled item is skipped");
356356
});
357+
358+
it.only('should focus next interactive element if TAB is pressed when focus is on "More" growing button', () => {
359+
const growingListButton = $('#growingListButton').shadow$("div[load-more-inner]");
360+
const nextInteractiveElement = $('#nextInteractiveElement');
361+
362+
growingListButton.click() // focus growing button
363+
growingListButton.keys("Tab") // focus next list
364+
365+
assert.strictEqual(nextInteractiveElement.isFocused(), true, "Focus is moved to next interactive element.");
366+
});
357367
});

0 commit comments

Comments
 (0)