@@ -7,6 +7,16 @@ import { useCallback, useEffect } from 'react';
77import type { CellInstance , CellType , ReactTableHooks , TableInstance } from '../types/index.js' ;
88import { NAVIGATION_KEYS } from '../util/index.js' ;
99
10+ const NON_STANDARD_INTERACTIVE_ELEMENTS = [
11+ '[ui5-checkbox]' ,
12+ '[ui5-switch]' ,
13+ '[ui5-radio-button]' ,
14+ '[ui5-rating-indicator]' ,
15+ '[ui5-segmented-button]' ,
16+ '[ui5-select]' ,
17+ '[ui5-slider]' ,
18+ ] ;
19+
1020/**
1121 * A plugin hook that enables F2-based cell editing for interactive elements inside a cell.
1222 *
@@ -133,16 +143,20 @@ useF2CellEdit.useCallbackRef = <T extends HTMLElement = HTMLElement>(props: Cell
133143 return useCallback (
134144 ( node : T | null ) => {
135145 if ( node ) {
136- if ( node . tagName . startsWith ( 'UI5' ) ) {
137- void ( node as unknown as Ui5DomRef )
138- . getFocusDomRefAsync ( )
139- . then ( ( focusNode ) => focusNode . setAttribute ( 'tabindex' , cellContentTabIndex ) )
140- . catch ( ( ) => {
141- // fail silently
142- } ) ;
143- } else {
144- node . setAttribute ( 'tabindex' , cellContentTabIndex ) ;
145- }
146+ const setTabIndex = ( el : Element | Ui5DomRef ) => {
147+ if ( typeof ( el as Ui5DomRef ) . getFocusDomRefAsync === 'function' ) {
148+ void ( el as Ui5DomRef )
149+ . getFocusDomRefAsync ( )
150+ . then ( ( resolved ) => setTabIndex ( resolved ) )
151+ . catch ( ( ) => {
152+ // fail silently
153+ } ) ;
154+ } else {
155+ el . setAttribute ( 'tabindex' , cellContentTabIndex ) ;
156+ }
157+ } ;
158+
159+ setTabIndex ( node ) ;
146160 }
147161 } ,
148162 [ cellContentTabIndex ] ,
@@ -175,6 +189,7 @@ function findFirstFocusableInside(element: HTMLElement) {
175189 'textarea' ,
176190 'select' ,
177191 '[tabindex]:not([tabindex="-1"])' ,
192+ ...NON_STANDARD_INTERACTIVE_ELEMENTS ,
178193 ] ;
179194
180195 if ( child . matches ( focusableSelectors . join ( ',' ) ) ) {
0 commit comments