@@ -54,7 +54,7 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
5454 /** state of width columns */
5555 const { columnWidthState, setColumnWidthState } = useContext ( HeaderContext ) ;
5656 /** Column values */
57- const { id, key, dataType } = headerMenuProps . column ;
57+ const { id, key, dataType, position } = headerMenuProps . column ;
5858 const [ keyState , setkeyState ] = useState ( dbTrim ( key ) ) ;
5959 const [ popperElement , setPopperElement ] = useState ( null ) ;
6060 const [ inputRef , setInputRef ] = useState ( null ) ;
@@ -116,7 +116,7 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
116116 type : ActionTypes . ADD_COLUMN_TO_LEFT ,
117117 columnId : id ,
118118 focus : false ,
119- columnInfo : adjustWidthOfTheColumn ( ) ,
119+ columnInfo : adjustWidthOfTheColumn ( position - 1 ) ,
120120 } ) ;
121121 setExpanded ( false ) ;
122122 } ,
@@ -129,7 +129,7 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
129129 type : ActionTypes . ADD_COLUMN_TO_RIGHT ,
130130 columnId : id ,
131131 focus : false ,
132- columnInfo : adjustWidthOfTheColumn ( ) ,
132+ columnInfo : adjustWidthOfTheColumn ( position + 1 ) ,
133133 } ) ;
134134 setExpanded ( false ) ;
135135 } ,
@@ -217,7 +217,7 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
217217 columnId : id ,
218218 accessor : keyState ,
219219 label : labelState ,
220- columnInfo : adjustWidthOfTheColumn ( ) ,
220+ columnInfo : adjustWidthOfTheColumn ( position ) ,
221221 } ) ;
222222 setExpanded ( false ) ;
223223 setkeyState ( dbTrim ( labelState ) ) ;
@@ -241,15 +241,15 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
241241 e . preventDefault ( ) ;
242242 }
243243
244- function adjustWidthOfTheColumn ( ) {
244+ function adjustWidthOfTheColumn ( wantedPosition : number ) {
245245 const columnNumber =
246- initialState . columns . length + 1 - initialState . shadowColumns . length ;
246+ initialState . columns . length - initialState . shadowColumns . length ;
247247 const columnName = `newColumn${ columnNumber } ` ;
248248 const columnLabel = `New Column ${ columnNumber } ` ;
249249 setColumnWidthState (
250250 recalculateColumnWidth ( columnWidthState , columnName , columnLabel )
251251 ) ;
252- return { name : columnName , position : columnNumber , label : columnLabel } ;
252+ return { name : columnName , position : wantedPosition , label : columnLabel } ;
253253 }
254254
255255 function handleChangeToggleInlineFrontmatter ( e : any ) {
0 commit comments