From 5da902934badca1055d991e54fba85a3bc00bd9a Mon Sep 17 00:00:00 2001 From: Matheus Wichman Date: Mon, 29 Mar 2021 11:05:54 -0300 Subject: [PATCH] Call getColumnFromField from the apiRef --- .../grid/hooks/features/columns/useGridColumns.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/grid/_modules_/grid/hooks/features/columns/useGridColumns.ts b/packages/grid/_modules_/grid/hooks/features/columns/useGridColumns.ts index f94c6244387f2..961638c644fdc 100644 --- a/packages/grid/_modules_/grid/hooks/features/columns/useGridColumns.ts +++ b/packages/grid/_modules_/grid/hooks/features/columns/useGridColumns.ts @@ -1,8 +1,5 @@ import * as React from 'react'; -import { - GRID_COLUMNS_UPDATED, - GRID_COLUMN_ORDER_CHANGE, -} from '../../../constants/eventsConstants'; +import { GRID_COLUMNS_UPDATED, GRID_COLUMN_ORDER_CHANGE } from '../../../constants/eventsConstants'; import { GridApiRef } from '../../../models/api/gridApiRef'; import { GridColumnApi } from '../../../models/api/gridColumnApi'; import { gridCheckboxSelectionColDef } from '../../../models/colDef/gridCheckboxSelection'; @@ -174,13 +171,13 @@ export function useGridColumns(columns: GridColumns, apiRef: GridApiRef): void { if (oldIndexPosition === targetIndexPosition) { return; } - + logger.debug(`Moving column ${field} to index ${targetIndexPosition}`); apiRef.current.publishEvent(GRID_COLUMN_ORDER_CHANGE, { field, element: apiRef.current.getColumnHeaderElement(field), - colDef: getColumnFromField(field), + colDef: apiRef.current.getColumnFromField(field), targetIndex: targetIndexPosition, oldIndex: oldIndexPosition, api: apiRef.current, @@ -190,7 +187,7 @@ export function useGridColumns(columns: GridColumns, apiRef: GridApiRef): void { updatedColumns.splice(targetIndexPosition, 0, updatedColumns.splice(oldIndexPosition, 1)[0]); updateState({ ...gridState.columns, all: updatedColumns }); }, - [apiRef, getColumnFromField, gridState.columns, logger, updateState], + [apiRef, gridState.columns, logger, updateState], ); const colApi: GridColumnApi = {