File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ type Props = {
1414} ;
1515
1616const ActiveCell : React . FC < Props > = ( props ) => {
17+ const rootRef = React . useRef < HTMLDivElement > ( null ) ;
1718 const { getBindingsForCell } = props ;
1819
1920 const dispatch = useDispatch ( ) ;
@@ -60,6 +61,13 @@ const ActiveCell: React.FC<Props> = (props) => {
6061 [ setCellData , active ]
6162 ) ;
6263
64+ React . useEffect ( ( ) => {
65+ const root = rootRef . current ;
66+ if ( ! hidden && root ) {
67+ root . focus ( ) ;
68+ }
69+ } , [ rootRef , hidden ] ) ;
70+
6371 React . useEffect ( ( ) => {
6472 const prevActive = prevActiveRef . current ;
6573 const prevCell = prevCellRef . current ;
@@ -101,12 +109,14 @@ const ActiveCell: React.FC<Props> = (props) => {
101109
102110 return hidden ? null : (
103111 < div
112+ ref = { rootRef }
104113 className = { classnames (
105114 "Spreadsheet__active-cell" ,
106115 `Spreadsheet__active-cell--${ mode } `
107116 ) }
108117 style = { dimensions }
109118 onClick = { mode === "view" && ! readOnly ? edit : undefined }
119+ tabIndex = { 0 }
110120 >
111121 { mode === "edit" && active && (
112122 < DataEditor
You can’t perform that action at this time.
0 commit comments