@@ -2103,6 +2103,159 @@ describe('AnalyticalTable', () => {
2103
2103
cy . get ( '[data-visible-row-index="5"][data-visible-column-index="3"]' ) . should ( 'have.text' , '90' ) ;
2104
2104
} ) ;
2105
2105
2106
+ it ( 'keyboard navigation' , ( ) => {
2107
+ cy . mount ( < AnalyticalTable data = { generateMoreData ( 50 ) } columns = { columns } /> ) ;
2108
+ cy . findByText ( 'Name-0' ) . should ( 'be.visible' ) ;
2109
+ cy . get ( '[tabindex="0"]' )
2110
+ . should ( 'have.attr' , 'data-component-name' , 'AnalyticalTableContainer' )
2111
+ . should ( 'have.length' , 1 ) ;
2112
+
2113
+ cy . window ( ) . focus ( ) ;
2114
+ cy . realPress ( 'Tab' ) ;
2115
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '0' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2116
+
2117
+ cy . realPress ( 'ArrowDown' ) ;
2118
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '1' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2119
+ cy . realPress ( 'ArrowRight' ) ;
2120
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '1' ) . should ( 'have.attr' , 'data-column-index' , '1' ) ;
2121
+ cy . realPress ( 'ArrowUp' ) ;
2122
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '0' ) . should ( 'have.attr' , 'data-column-index' , '1' ) ;
2123
+ cy . realPress ( 'ArrowLeft' ) ;
2124
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '0' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2125
+
2126
+ cy . realPress ( 'End' ) ;
2127
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '0' ) . should ( 'have.attr' , 'data-column-index' , '2' ) ;
2128
+ cy . realPress ( 'Home' ) ;
2129
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '0' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2130
+
2131
+ cy . realPress ( 'PageDown' ) ;
2132
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '1' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2133
+ cy . realPress ( 'PageDown' ) ;
2134
+ // last currently rendered row
2135
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '22' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2136
+ cy . realPress ( 'PageDown' ) ;
2137
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '36' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2138
+ cy . realPress ( 'PageDown' ) ;
2139
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '50' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2140
+ cy . realPress ( 'PageUp' ) ;
2141
+ // first currently rendered row
2142
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '29' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2143
+ cy . realPress ( 'PageUp' ) ;
2144
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '15' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2145
+ cy . realPress ( 'PageUp' ) ;
2146
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '1' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2147
+ cy . realPress ( 'PageUp' ) ;
2148
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '0' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2149
+
2150
+ cy . mount (
2151
+ < AnalyticalTable
2152
+ data = { generateMoreData ( 50 ) }
2153
+ columns = { [ ...columns . slice ( 0 , 2 ) , { id : 'button' , Cell : ( ) => < Button > Button</ Button > } ] }
2154
+ />
2155
+ ) ;
2156
+
2157
+ cy . findByText ( 'Name-0' ) . should ( 'be.visible' ) ;
2158
+ cy . window ( ) . focus ( ) ;
2159
+ cy . realPress ( 'Tab' ) ;
2160
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '0' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2161
+ cy . realPress ( 'Tab' ) ;
2162
+ cy . focused ( ) . should ( 'have.attr' , 'ui5-button' ) ;
2163
+ cy . realPress ( 'ArrowLeft' ) ;
2164
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '1' ) . should ( 'have.attr' , 'data-column-index' , '1' ) ;
2165
+ cy . realPress ( 'Tab' ) ;
2166
+ cy . focused ( ) . should ( 'have.attr' , 'ui5-button' ) ;
2167
+ cy . realPress ( 'ArrowDown' ) ;
2168
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '2' ) . should ( 'have.attr' , 'data-column-index' , '2' ) ;
2169
+ cy . realPress ( [ 'Shift' , 'Tab' ] ) ;
2170
+ cy . focused ( ) . should ( 'have.attr' , 'ui5-button' ) ;
2171
+
2172
+ const renderSubComp = ( row ) => {
2173
+ if ( row . id === '2' ) {
2174
+ return null ;
2175
+ }
2176
+ return < div style = { { height : '50px' , width : '100%' , background : 'cadetblue' } } > SubComponent</ div > ;
2177
+ } ;
2178
+
2179
+ cy . mount (
2180
+ < AnalyticalTable
2181
+ data = { generateMoreData ( 50 ) }
2182
+ columns = { columns . slice ( 0 , 2 ) }
2183
+ alwaysShowSubComponent
2184
+ renderRowSubComponent = { renderSubComp }
2185
+ />
2186
+ ) ;
2187
+ cy . findByText ( 'Name-0' ) . should ( 'be.visible' ) ;
2188
+ cy . window ( ) . focus ( ) ;
2189
+ cy . realPress ( 'Tab' ) ;
2190
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '0' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2191
+ cy . realPress ( 'ArrowDown' ) ;
2192
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '1' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2193
+ cy . realPress ( 'ArrowDown' ) ;
2194
+ cy . focused ( ) . should ( 'have.attr' , 'data-subcomponent-row-index' , '1' ) ;
2195
+ cy . realPress ( 'ArrowDown' ) ;
2196
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '2' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2197
+ cy . realPress ( 'ArrowDown' ) ;
2198
+ cy . focused ( ) . should ( 'have.attr' , 'data-subcomponent-row-index' , '2' ) ;
2199
+ cy . realPress ( 'ArrowDown' ) ;
2200
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '3' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2201
+ cy . realPress ( 'ArrowDown' ) ;
2202
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '4' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2203
+ cy . realPress ( 'ArrowRight' ) ;
2204
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '4' ) . should ( 'have.attr' , 'data-column-index' , '1' ) ;
2205
+ cy . realPress ( 'ArrowUp' ) ;
2206
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '3' ) . should ( 'have.attr' , 'data-column-index' , '1' ) ;
2207
+ cy . realPress ( 'ArrowUp' ) ;
2208
+ cy . focused ( ) . should ( 'have.attr' , 'data-subcomponent-row-index' , '2' ) ;
2209
+ cy . realPress ( 'ArrowUp' ) ;
2210
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '2' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2211
+
2212
+ const renderSubComp2 = ( row ) => {
2213
+ if ( row . id === '2' ) {
2214
+ return null ;
2215
+ }
2216
+ return (
2217
+ < div style = { { height : '50px' , width : '100%' , background : 'cadetblue' } } >
2218
+ < Button data-subcomponent-active-element > Active</ Button >
2219
+ </ div >
2220
+ ) ;
2221
+ } ;
2222
+
2223
+ cy . mount (
2224
+ < AnalyticalTable
2225
+ data = { generateMoreData ( 50 ) }
2226
+ columns = { columns . slice ( 0 , 2 ) }
2227
+ alwaysShowSubComponent
2228
+ renderRowSubComponent = { renderSubComp2 }
2229
+ />
2230
+ ) ;
2231
+ cy . findByText ( 'Name-0' ) . should ( 'be.visible' ) ;
2232
+ cy . window ( ) . focus ( ) ;
2233
+ cy . realPress ( 'Tab' ) ;
2234
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '0' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2235
+ cy . realPress ( 'ArrowDown' ) ;
2236
+ cy . focused ( ) . should ( 'have.attr' , 'data-row-index' , '1' ) . should ( 'have.attr' , 'data-column-index' , '0' ) ;
2237
+ cy . realPress ( 'ArrowDown' ) ;
2238
+ cy . focused ( ) . should ( 'have.attr' , 'data-subcomponent-row-index' , '1' ) ;
2239
+ cy . realPress ( 'Tab' ) ;
2240
+ cy . focused ( ) . should ( 'have.attr' , 'ui5-button' ) ;
2241
+ cy . realPress ( 'ArrowDown' ) ;
2242
+ cy . focused ( ) . should ( 'have.attr' , 'data-subcomponent-row-index' , '1' ) ;
2243
+ cy . realPress ( 'Tab' ) ;
2244
+ cy . focused ( ) . should ( 'have.attr' , 'ui5-button' ) ;
2245
+ cy . realPress ( 'ArrowUp' ) ;
2246
+ cy . focused ( ) . should ( 'have.attr' , 'data-subcomponent-row-index' , '1' ) ;
2247
+ cy . realPress ( 'Tab' ) ;
2248
+ cy . focused ( ) . should ( 'have.attr' , 'ui5-button' ) ;
2249
+ cy . realPress ( 'ArrowLeft' ) ;
2250
+ cy . focused ( ) . should ( 'have.attr' , 'data-subcomponent-row-index' , '1' ) ;
2251
+ cy . realPress ( 'Tab' ) ;
2252
+ cy . focused ( ) . should ( 'have.attr' , 'ui5-button' ) ;
2253
+ cy . realPress ( 'ArrowRight' ) ;
2254
+ cy . focused ( ) . should ( 'have.attr' , 'data-subcomponent-row-index' , '1' ) ;
2255
+ cy . realPress ( 'Tab' ) ;
2256
+ cy . focused ( ) . should ( 'have.attr' , 'ui5-button' ) ;
2257
+ } ) ;
2258
+
2106
2259
cypressPassThroughTestsFactory ( AnalyticalTable , { data, columns } ) ;
2107
2260
} ) ;
2108
2261
0 commit comments