File tree 3 files changed +34
-4
lines changed
3 files changed +34
-4
lines changed Original file line number Diff line number Diff line change 3
3
tabindex =" {{ _tabIndex }} "
4
4
@focusin =" {{ _onfocusin }} "
5
5
@click =" {{ _onrowclick }} "
6
+ @keydown =" {{ _onkeydown }} "
7
+ @keyup =" {{ _onkeyup }} "
6
8
aria-label =" {{ ariaLabelText }} "
7
9
data-sap-focus-ref
8
10
part =" row"
21
23
22
24
{{ #if shouldPopin }}
23
25
{{ #each popinCells }}
24
- <tr part =" popin-row" role =" row" class =" {{ this.classes }} " @click =" {{ ../_onrowclick }} " >
26
+ <tr part =" popin-row" role =" row" class =" {{ this.classes }} "
27
+ @click =" {{ ../_onrowclick }} "
28
+ @keydown =" {{ ../_onkeydown }} "
29
+ @keyup =" {{ ../_onkeyup }} " >
25
30
<td colspan =" {{ ../visibleCellsCount }} " role =" cell" >
26
31
{{ #if this.popinText }}
27
32
<span class =" ui5-table-row-popin-title" >{{ this.popinText }} :</span >
Original file line number Diff line number Diff line change 1
1
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js" ;
2
2
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js" ;
3
+ import { isSpace , isEnter } from "@ui5/webcomponents-base/dist/Keys.js" ;
4
+
5
+ // Template
3
6
import TableRowTemplate from "./generated/templates/TableRowTemplate.lit.js" ;
4
7
5
8
// Styles
@@ -97,6 +100,22 @@ class TableRow extends UI5Element {
97
100
this . fireEvent ( "row-click" , { row : this } ) ;
98
101
}
99
102
103
+ _onkeydown ( event ) {
104
+ if ( isEnter ( event ) ) {
105
+ this . fireEvent ( "row-click" , { row : this } ) ;
106
+ }
107
+
108
+ if ( isSpace ( event ) ) {
109
+ event . preventDefault ( ) ;
110
+ }
111
+ }
112
+
113
+ _onkeyup ( event ) {
114
+ if ( isSpace ( event ) ) {
115
+ this . fireEvent ( "row-click" , { row : this } ) ;
116
+ }
117
+ }
118
+
100
119
_getActiveElementTagName ( ) {
101
120
return document . activeElement . localName . toLocaleLowerCase ( ) ;
102
121
}
Original file line number Diff line number Diff line change @@ -43,18 +43,24 @@ describe("Table general interaction", () => {
43
43
assert . strictEqual ( tableLabel . getHTML ( false ) , "Number of poppedColumns: 4" , "popinChange should be fired and columns should be 4" ) ;
44
44
} ) ;
45
45
46
- it ( "tests rowClick is fired" , ( ) => {
46
+ it ( "tests row-click is fired" , ( ) => {
47
47
const lbl = browser . $ ( "#testRowClickResult" ) ;
48
48
const cellInRow1 = browser . $ ( "#testRowClickCell1" ) ;
49
49
const cellInRow2 = browser . $ ( "#testRowClickCell2" ) ;
50
50
const row1Data = "Dublin" ;
51
51
const row2Data = "London" ;
52
52
53
53
cellInRow1 . click ( ) ;
54
- assert . ok ( lbl . getHTML ( ) . indexOf ( row1Data ) , "Event rowClick fired and intercepted." ) ;
54
+ assert . ok ( lbl . getHTML ( ) . indexOf ( row1Data ) , "Event row-click fired and intercepted." ) ;
55
55
56
56
cellInRow2 . click ( ) ;
57
- assert . ok ( lbl . getHTML ( ) . indexOf ( row2Data ) , "Event rowClick fired and intercepted." ) ;
57
+ assert . ok ( lbl . getHTML ( ) . indexOf ( row2Data ) , "Event row-click fired and intercepted." ) ;
58
+
59
+ cellInRow1 . keys ( "Space" ) ;
60
+ assert . ok ( lbl . getHTML ( ) . indexOf ( row1Data ) , "Event row-click fired and intercepted." ) ;
61
+
62
+ cellInRow2 . keys ( "Enter" ) ;
63
+ assert . ok ( lbl . getHTML ( ) . indexOf ( row2Data ) , "Event row-click fired and intercepted." ) ;
58
64
} ) ;
59
65
60
66
it ( "tests row aria-label value" , ( ) => {
You can’t perform that action at this time.
0 commit comments