File tree 3 files changed +14
-2
lines changed
3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 1
1
import ListItem from "./ListItem.js" ;
2
2
import CustomListItemTemplate from "./generated/templates/CustomListItemTemplate.lit.js" ;
3
+ import { isTabNext , isTabPrevious } from "@ui5/webcomponents-base/dist/Keys.js" ;
3
4
4
5
// Styles
5
6
import customListItemCss from "./generated/themes/CustomListItem.css.js" ;
@@ -55,15 +56,19 @@ class CustomListItem extends ListItem {
55
56
}
56
57
57
58
_onkeydown ( event ) {
58
- if ( ! this . focused ) {
59
+ const isTab = isTabNext ( event ) || isTabPrevious ( event ) ;
60
+
61
+ if ( ! isTab && ! this . focused ) {
59
62
return ;
60
63
}
61
64
62
65
super . _onkeydown ( event ) ;
63
66
}
64
67
65
68
_onkeyup ( event ) {
66
- if ( ! this . focused ) {
69
+ const isTab = isTabNext ( event ) || isTabPrevious ( event ) ;
70
+
71
+ if ( ! isTab && ! this . focused ) {
67
72
return ;
68
73
}
69
74
Original file line number Diff line number Diff line change 97
97
< ui5-radiobutton text ="Option C " disabled ="disabled "> </ ui5-radiobutton >
98
98
</ ui5-li-custom >
99
99
</ ui5-list >
100
+ < ui5-button id ="randomBtn "> Random button</ ui5-button >
100
101
101
102
< ui5-list id ="no-data-list " header-text ="API: noDataText " separators ="None " no-data-text ="No Data Available "> </ ui5-list >
102
103
Original file line number Diff line number Diff line change @@ -185,6 +185,7 @@ describe("List Tests", () => {
185
185
const itemBtn = $ ( "ui5-button.itemBtn" ) ;
186
186
const itemLink = $ ( "ui5-link.itemLink" ) ;
187
187
const itemRadioBtn = $ ( "ui5-radiobutton.itemRadio" ) ;
188
+ const randomBtn = $ ( "#randomBtn" ) ;
188
189
189
190
headerBtn . click ( ) ;
190
191
assert . strictEqual ( headerBtn . isFocused ( ) , true , "header btn is focused" ) ;
@@ -205,6 +206,11 @@ describe("List Tests", () => {
205
206
// and go to the "Option B" radio button
206
207
itemLink . keys ( "Tab" ) ;
207
208
assert . strictEqual ( itemRadioBtn . isFocused ( ) , true , "the last tabbable element (radio) is focused" ) ;
209
+
210
+ // act: TAB from the "Option B" radio button - the focus should leave the ui5-list
211
+ // and Random button should be focused
212
+ itemLink . keys ( "Tab" ) ;
213
+ assert . strictEqual ( randomBtn . isFocused ( ) , true , "element outside of the list is focused" ) ;
208
214
} ) ;
209
215
210
216
it ( "does not focus next / prev item when right / left arrow is pressed" , ( ) => {
You can’t perform that action at this time.
0 commit comments