File tree Expand file tree Collapse file tree 3 files changed +17
-6
lines changed
packages/orchestrator-ui-components/src/components/WfoTable/WfoTable Expand file tree Collapse file tree 3 files changed +17
-6
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @orchestrator-ui/orchestrator-ui-components ' : minor
3+ ---
4+
5+ Adds resizable table columns
Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ export const WfoDragHandler: FC<WfoDragHandlerProps> = ({
3030 } ;
3131
3232 const { dragAndDropStyle } = useWithOrchestratorTheme ( getWfoTableStyles ) ;
33- let startWidth : number ;
3433
3534 return (
3635 < div >
@@ -44,7 +43,8 @@ export const WfoDragHandler: FC<WfoDragHandlerProps> = ({
4443 const thElement = headerRowRef . current . querySelector (
4544 `th[data-field-name="${ fieldName } "]` ,
4645 ) as HTMLTableCellElement ;
47- startWidth = thElement . getBoundingClientRect ( ) . width ;
46+ const startWidth =
47+ thElement . getBoundingClientRect ( ) . width ;
4848 const newWidth = startWidth + data . x ;
4949
5050 onUpdateColumWidth (
Original file line number Diff line number Diff line change 1- import React , { useState } from 'react' ;
1+ import React , { useEffect , useState } from 'react' ;
22import type { CSSProperties , ReactNode } from 'react' ;
33
44import { useTranslations } from 'next-intl' ;
@@ -117,6 +117,15 @@ export const WfoTable = <T extends object>({
117117 onRowClick,
118118 className,
119119} : WfoTableProps < T > ) => {
120+ const [ localColumnConfig , setLocalColumnConfig ] =
121+ useState < WfoTableColumnConfig < T > > ( columnConfig ) ;
122+
123+ useEffect ( ( ) => {
124+ if ( ! localColumnConfig || localColumnConfig !== columnConfig ) {
125+ setLocalColumnConfig ( columnConfig ) ;
126+ }
127+ } , [ columnConfig ] ) ; // Dont add localColumnConfig to dependencies, it should trigger on local column changes
128+
120129 const {
121130 tableContainerStyle,
122131 tableStyle,
@@ -128,9 +137,6 @@ export const WfoTable = <T extends object>({
128137 } = useWithOrchestratorTheme ( getWfoTableStyles ) ;
129138 const t = useTranslations ( 'common' ) ;
130139
131- const [ localColumnConfig , setLocalColumnConfig ] =
132- useState < WfoTableColumnConfig < T > > ( columnConfig ) ;
133-
134140 const sortedVisibleColumns = getSortedVisibleColumns (
135141 columnConfig ,
136142 columnOrder ,
You can’t perform that action at this time.
0 commit comments