@@ -103,31 +103,32 @@ const rows: DataViewTr[] = repositories.map(({ id, name, branches, prs, workspac
103103 { cell : < ActionsColumn items = { rowActions } /> , props : { isActionCell : true } }
104104] ) ;
105105
106- const columns : DataViewTh [ ] = [
107- null ,
108- 'Repositories' ,
109- {
110- cell : 'col' ,
111- resizableProps : { isResizable : true }
112- } ,
113- 'Pull requests' ,
114- { cell : 'Workspaces' , props : { info : { tooltip : 'More information' } } } ,
115- { cell : 'Last commit' , props : { sort : { sortBy : { } , columnIndex : 4 } } }
116- ] ;
117-
118106const ouiaId = 'TableExample' ;
119107
120108export const ResizableColumnsExample : FunctionComponent = ( ) => {
121109 const [ screenReaderText , setScreenReaderText ] = useState ( '' ) ;
122110
123- if ( columns [ 2 ] && isDataViewThObject ( columns [ 2 ] ) && columns [ 2 ] . resizableProps ) {
124- columns [ 2 ] . resizableProps . onResize = ( _e , width ) => {
125- // eslint-disable-next-line no-console
126- console . log ( 'resized width: ' , width ) ;
127- setScreenReaderText ( `Column ${ width } pixels` ) ;
128- } ;
129- columns [ 2 ] . resizableProps . screenreaderText = screenReaderText ;
130- }
111+ const onResize = ( _e , width ) => {
112+ // eslint-disable-next-line no-console
113+ console . log ( 'resized width: ' , width ) ;
114+ setScreenReaderText ( `Column ${ width } pixels` ) ;
115+ } ;
116+
117+ const columns : DataViewTh [ ] = [
118+ null ,
119+ 'Repositories' ,
120+ {
121+ cell : 'col' ,
122+ resizableProps : {
123+ isResizable : true ,
124+ onResize,
125+ screenreaderText : screenReaderText
126+ }
127+ } ,
128+ 'Pull requests' ,
129+ { cell : 'Workspaces' , props : { info : { tooltip : 'More information' } } } ,
130+ { cell : 'Last commit' , props : { sort : { sortBy : { } , columnIndex : 4 } } }
131+ ] ;
131132
132133 return < DataViewTable isResizable aria-label = "Repositories table" ouiaId = { ouiaId } columns = { columns } rows = { rows } /> ;
133134} ;
0 commit comments