@@ -25,6 +25,7 @@ import {
2525import { useManualRowSelect } from './pluginHooks/useManualRowSelect' ;
2626import { useRowDisableSelection } from './pluginHooks/useRowDisableSelection' ;
2727import { cssVarToRgb , cypressPassThroughTestsFactory } from '@/cypress/support/utils' ;
28+ import type { RowType } from '@/packages/main/src/components/AnalyticalTable/types/index.js' ;
2829import { getUi5TagWithSuffix } from '@/packages/main/src/internal/utils.js' ;
2930
3031const generateMoreData = ( count ) => {
@@ -3416,6 +3417,78 @@ describe('AnalyticalTable', () => {
34163417 cy . get ( '[data-component-name="ATHeaderPopover"]' ) . should ( 'not.exist' ) ;
34173418 } ) ;
34183419
3420+ it ( 'Interactive Cell content' , ( ) => {
3421+ const columns : AnalyticalTableColumnDefinition [ ] = [
3422+ { Header : 'Name' , accessor : 'name' } ,
3423+ {
3424+ Header : 'Custom' ,
3425+ id : 'custom' ,
3426+ Cell : ( { row } : { row : RowType } ) => {
3427+ switch ( row . index ) {
3428+ case 0 :
3429+ return < Input /> ;
3430+ case 1 :
3431+ return (
3432+ < Button
3433+ onClick = { ( ) => {
3434+ document . querySelector ( '[data-testid="btn-was-clicked"]' ) . textContent = 'true' ;
3435+ } }
3436+ >
3437+ Click
3438+ </ Button >
3439+ ) ;
3440+ default :
3441+ return < Input /> ;
3442+ }
3443+ }
3444+ }
3445+ ] ;
3446+ const TestComp = ( ) => {
3447+ const [ selected , setSelected ] = useState ( { } ) ;
3448+ return (
3449+ < >
3450+ < AnalyticalTable
3451+ data = { data }
3452+ columns = { columns }
3453+ selectionMode = "Multiple"
3454+ onRowSelect = { ( e ) => {
3455+ setSelected ( e . detail . selectedRowIds ) ;
3456+ } }
3457+ />
3458+ < span data-testid = "sel" > { JSON . stringify ( selected ) } </ span >
3459+ < span data-testid = "btn-was-clicked" />
3460+ </ >
3461+ ) ;
3462+ } ;
3463+ cy . mount ( < TestComp /> ) ;
3464+ // for some reason only required for React18
3465+ cy . wait ( 300 ) ;
3466+
3467+ // Pressing SPACE inside input components should work
3468+ // Focus: (1,0) -> (col, row)
3469+ cy . realPress ( 'Tab' ) ;
3470+ // (1,1)
3471+ cy . realPress ( 'ArrowDown' ) ;
3472+ cy . focused ( ) . realPress ( 'Space' ) ;
3473+ cy . findByTestId ( 'sel' ) . should ( 'have.text' , '{"0":true}' ) ;
3474+ // (2,1)
3475+ cy . realPress ( 'ArrowRight' ) ;
3476+ cy . focused ( ) . realPress ( 'Space' ) ;
3477+ cy . findByTestId ( 'sel' ) . should ( 'have.text' , '{}' ) ;
3478+ // Focus: Input (2,1)
3479+ cy . realPress ( 'Tab' ) ;
3480+ cy . focused ( ) . type ( '3Spaces 2Spaces ' ) ;
3481+ cy . focused ( ) . should ( 'have.value' , '3Spaces 2Spaces ' ) ;
3482+ cy . findByTestId ( 'sel' ) . should ( 'have.text' , '{}' ) ;
3483+ // (2,2)
3484+ cy . realPress ( 'ArrowDown' ) ;
3485+ // Focus: Button (2,2)
3486+ cy . realPress ( 'Tab' ) ;
3487+ cy . focused ( ) . realPress ( 'Space' ) ;
3488+ cy . findByTestId ( 'sel' ) . should ( 'have.text' , '{}' ) ;
3489+ cy . findByTestId ( 'btn-was-clicked' ) . should ( 'have.text' , 'true' ) ;
3490+ } ) ;
3491+
34193492 cypressPassThroughTestsFactory ( AnalyticalTable , { data, columns } ) ;
34203493} ) ;
34213494
0 commit comments