File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
packages/module/src/DataViewTh Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -53,20 +53,26 @@ export const DataViewTh: FC<DataViewThProps> = ({
5353 const thRef = useRef < HTMLTableCellElement > ( null ) ;
5454
5555 const [ width , setWidth ] = useState ( resizableProps ?. width ? resizableProps . width : 0 ) ;
56+ const [ screenreaderText , setScreenreaderText ] = useState ( resizableProps ?. screenreaderText || `Column ${ width . toFixed ( 0 ) } pixels` ) ;
57+ let currWidth = 0 ;
5658
5759 const isResizable = resizableProps ?. isResizable || false ;
5860 const increment = resizableProps ?. increment || 5 ;
5961 const shiftIncrement = resizableProps ?. shiftIncrement || 25 ;
6062 const resizeButtonAriaLabel = resizableProps ?. resizeButtonAriaLabel || `Resize ${ content } ` ;
6163 const onResize = resizableProps ?. onResize || undefined ;
62- const screenreaderText = resizableProps ?. screenreaderText || `Column ${ width } pixels` ;
6364
6465 const resizeButtonRef = useRef < HTMLButtonElement > ( null ) ;
6566 const setInitialVals = useRef ( true ) ;
6667 const dragOffset = useRef ( 0 ) ;
6768 const isResizing = useRef ( false ) ;
6869 const isInView = useRef ( true ) ;
69- let currWidth = 0 ;
70+
71+ useEffect ( ( ) => {
72+ if ( ! resizableProps ?. screenreaderText && currWidth > 0 ) {
73+ setScreenreaderText ( `Column ${ currWidth . toFixed ( 0 ) } pixels` ) ;
74+ }
75+ } , [ currWidth ] ) ;
7076
7177 useEffect ( ( ) => {
7278 if ( ! isResizable ) {
You can’t perform that action at this time.
0 commit comments