@@ -15,7 +15,7 @@ import MultiIcon from "components/img/Multi";
1515import HashIcon from "components/img/Hash" ;
1616import AdjustmentsIcon from "components/img/AdjustmentsIcon" ;
1717import React , { useContext , useEffect , useState } from "react" ;
18- import { ActionType } from "react-table" ;
18+ import { ActionType , Column } from "react-table" ;
1919import { usePopper } from "react-popper" ;
2020import { HeaderContext } from "components/contexts/HeaderContext" ;
2121import { FormControlLabel , FormGroup , Switch } from "@material-ui/core" ;
@@ -49,7 +49,7 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
4949 isInline,
5050 setIsInline,
5151 } = headerMenuProps ;
52- const { column, columns , rows, initialState } = headerMenuProps . headerProps ;
52+ const { column, rows, initialState } = headerMenuProps . headerProps ;
5353 const dispatch = ( headerMenuProps . headerProps as any ) . dataDispatch ;
5454 /** Column values */
5555 const [ keyState , setkeyState ] = useState ( dbTrim ( column . key ) ) ;
@@ -211,6 +211,9 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
211211 function persistLabelChange ( ) {
212212 // trim label will get a valid yaml key
213213 const newKey = dbTrim ( labelState ) ;
214+ const futureOrder = headerMenuProps . headerProps . allColumns . map (
215+ ( o : Column ) => ( o . id === column . id ? newKey : o . id )
216+ ) ;
214217 dispatch ( {
215218 type : ActionTypes . UPDATE_COLUMN_LABEL ,
216219 columnId : column . id ,
@@ -225,10 +228,15 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
225228 newKey ,
226229 labelState
227230 ) ;
231+
232+ /*
233+ To adjust column settings to the new key, we need to update the order
234+ of the columns with it and calculate the new width
235+ */
228236 delete columnWidthState . widthRecord [ column . id ] ;
229237 setColumnWidthState ( columnWidthState ) ;
238+ headerMenuProps . headerProps . setColumnOrder ( futureOrder ) ;
230239 }
231-
232240 function handleKeyDown ( e : any ) {
233241 if ( e . key === "Enter" ) {
234242 persistLabelChange ( ) ;
0 commit comments