@@ -49,7 +49,7 @@ export default function Header(headerProps: DatabaseHeaderProps) {
4949 /** Properties of header */
5050 const { setSortBy, rows, initialState } = headerProps ;
5151 /** Column values */
52- const { id, dataType, options } = headerProps . column ;
52+ const { id, dataType, options, position } = headerProps . column ;
5353 /** reducer asociated to database */
5454 // TODO typying improve
5555 const dataDispatch = ( headerProps as any ) . dataDispatch ;
@@ -83,7 +83,7 @@ export default function Header(headerProps: DatabaseHeaderProps) {
8383 break ;
8484 }
8585
86- function adjustWidthOfTheColumn ( ) {
86+ function adjustWidthOfTheColumn ( position : number ) {
8787 const columnNumber =
8888 initialState . columns . length + 1 - initialState . shadowColumns . length ;
8989 const columnName = `newColumn${ columnNumber } ` ;
@@ -93,15 +93,15 @@ export default function Header(headerProps: DatabaseHeaderProps) {
9393 ( columnLabel . length + WidthVariables . ICON_SPACING ) *
9494 WidthVariables . MAGIC_SPACING ;
9595 setColumnWidthState ( columnWidthState ) ;
96- return { name : columnName , position : columnNumber , label : columnLabel } ;
96+ return { name : columnName , position : position , label : columnLabel } ;
9797 }
9898
9999 function handlerAddColumnToLeft ( e : any ) {
100100 dataDispatch ( {
101101 type : ActionTypes . ADD_COLUMN_TO_LEFT ,
102102 columnId : MetadataColumns . ADD_COLUMN ,
103103 focus : true ,
104- columnInfo : adjustWidthOfTheColumn ( ) ,
104+ columnInfo : adjustWidthOfTheColumn ( position - 1 ) ,
105105 } ) ;
106106 }
107107
0 commit comments