@@ -21,6 +21,7 @@ const DEFAULT_COL_WIDTH = 180;
2121const MIN_COL_WIDTH = 80 ;
2222const ROW_HEIGHT = 34 ;
2323const GHOST_ROW_COUNT = 50 ;
24+ const LAST_COLUMN_RESIZE_GUTTER = 160 ;
2425
2526const columnHelper = createColumnHelper < DatasetRow > ( ) ;
2627
@@ -68,6 +69,7 @@ export function DatasetTable({
6869 selection : Selection ;
6970} ) {
7071 const tableContainerRef = useRef < HTMLDivElement > ( null ) ;
72+ const previousResizingColumnIdRef = useRef < string | false > ( false ) ;
7173 const [ containerHeight , setContainerHeight ] = useState ( 600 ) ;
7274
7375 useEffect ( ( ) => {
@@ -112,8 +114,16 @@ export function DatasetTable({
112114 const isBuilding = dataset . status === "building" ;
113115 const displayCount = isBuilding ? Math . max ( tableRows . length , GHOST_ROW_COUNT ) : tableRows . length ;
114116 const totalWidth = columnWidths . reduce ( ( sum , w ) => sum + w , 0 ) ;
117+ const tableContentWidth = totalWidth + LAST_COLUMN_RESIZE_GUTTER ;
115118 const resizingColumnId = table . getState ( ) . columnSizingInfo . isResizingColumn ;
116119
120+ useEffect ( ( ) => {
121+ if ( previousResizingColumnIdRef . current && ! resizingColumnId ) {
122+ persistWidths ( ) ;
123+ }
124+ previousResizingColumnIdRef . current = resizingColumnId ;
125+ } , [ resizingColumnId , persistWidths ] ) ;
126+
117127 const toggleRow = useCallback (
118128 ( id : string , shiftKey : boolean ) => {
119129 if ( shiftKey ) selection . shiftToggle ( id ) ;
@@ -143,7 +153,7 @@ export function DatasetTable({
143153 if ( resizingColumnId ) persistWidths ( ) ;
144154 } }
145155 >
146- < div style = { { minWidth : totalWidth } } >
156+ < div style = { { minWidth : tableContentWidth } } >
147157 < TableHeader
148158 headers = { headers }
149159 columns = { dataset . columns }
0 commit comments