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
@@ -98,6 +101,22 @@ class TableRow extends UI5Element {
98
101
this . fireEvent ( "row-click" , { row : this } ) ;
99
102
}
100
103
104
+ _onkeydown ( event ) {
105
+ if ( isEnter ( event ) ) {
106
+ this . fireEvent ( "row-click" , { row : this } ) ;
107
+ }
108
+
109
+ if ( isSpace ( event ) ) {
110
+ event . preventDefault ( ) ;
111
+ }
112
+ }
113
+
114
+ _onkeyup ( event ) {
115
+ if ( isSpace ( event ) ) {
116
+ this . fireEvent ( "row-click" , { row : this } ) ;
117
+ }
118
+ }
119
+
101
120
_getActiveElementTagName ( ) {
102
121
return document . activeElement . localName . toLocaleLowerCase ( ) ;
103
122
}
Original file line number Diff line number Diff line change @@ -45,18 +45,24 @@ describe("Table general interaction", () => {
45
45
assert . strictEqual ( tableLabel . getHTML ( false ) , "Number of poppedColumns: 4" , "popinChange should be fired and columns should be 4" ) ;
46
46
} ) ;
47
47
48
- it ( "tests rowClick is fired" , ( ) => {
48
+ it ( "tests row-click is fired" , ( ) => {
49
49
const lbl = browser . $ ( "#testRowClickResult" ) ;
50
50
const cellInRow1 = browser . $ ( "#testRowClickCell1" ) ;
51
51
const cellInRow2 = browser . $ ( "#testRowClickCell2" ) ;
52
52
const row1Data = "Dublin" ;
53
53
const row2Data = "London" ;
54
54
55
55
cellInRow1 . click ( ) ;
56
- assert . ok ( lbl . getHTML ( ) . indexOf ( row1Data ) , "Event rowClick fired and intercepted." ) ;
56
+ assert . ok ( lbl . getHTML ( ) . indexOf ( row1Data ) , "Event row-click fired and intercepted." ) ;
57
57
58
58
cellInRow2 . click ( ) ;
59
- assert . ok ( lbl . getHTML ( ) . indexOf ( row2Data ) , "Event rowClick fired and intercepted." ) ;
59
+ assert . ok ( lbl . getHTML ( ) . indexOf ( row2Data ) , "Event row-click fired and intercepted." ) ;
60
+
61
+ cellInRow1 . keys ( "Space" ) ;
62
+ assert . ok ( lbl . getHTML ( ) . indexOf ( row1Data ) , "Event row-click fired and intercepted." ) ;
63
+
64
+ cellInRow2 . keys ( "Enter" ) ;
65
+ assert . ok ( lbl . getHTML ( ) . indexOf ( row2Data ) , "Event row-click fired and intercepted." ) ;
60
66
} ) ;
61
67
62
68
it ( "tests row aria-label value" , ( ) => {
You can’t perform that action at this time.
0 commit comments