@linzjs/step-ag-grid 27.0.0 → 27.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2937,14 +2937,15 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
2937
2937
  };
2938
2938
  });
2939
2939
  }, [params.columnDefs, params.loading, params.readOnly, params.defaultColDef?.editable]);
2940
+ const hasExternallySelectedItems = !!params.setExternalSelectedItems;
2940
2941
  /**
2941
2942
  * When grid is ready set the apis to the grid context and sync selected items to grid.
2942
2943
  */
2943
2944
  const onGridReady = useCallback((event) => {
2944
- setApis(event.api, dataTestId);
2945
+ setApis(event.api, hasExternallySelectedItems, dataTestId);
2945
2946
  event.api.showNoRowsOverlay();
2946
2947
  synchroniseExternallySelectedItemsToGrid();
2947
- }, [dataTestId, setApis, synchroniseExternallySelectedItemsToGrid]);
2948
+ }, [dataTestId, hasExternallySelectedItems, setApis, synchroniseExternallySelectedItemsToGrid]);
2948
2949
  /**
2949
2950
  * When the grid is being initialized the data may be empty.
2950
2951
  * This will resize columns when we have at least one row.
@@ -2997,7 +2998,7 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
2997
2998
  * Handle single click edits
2998
2999
  */
2999
3000
  const onCellClicked = useCallback((event) => {
3000
- if (event.colDef?.cellRendererParams?.singleClickEdit ?? singleClickEdit) {
3001
+ if (event.colDef.singleClickEdit ?? singleClickEdit) {
3001
3002
  void startCellEditing({ rowId: event.data.id, colId: event.column.getColId() });
3002
3003
  }
3003
3004
  }, [singleClickEdit, startCellEditing]);
@@ -4986,11 +4987,9 @@ const GridPopoverMenu = (colDef, custom) => GridCell({
4986
4987
  exportable: false,
4987
4988
  cellStyle: { flex: 1, justifyContent: 'center' },
4988
4989
  cellRenderer: GridRenderPopoutMenuCell,
4990
+ // Menus open on single click, this parameter is picked up in Grid.tsx
4991
+ singleClickEdit: true,
4989
4992
  ...colDef,
4990
- cellRendererParams: {
4991
- // Menus open on single click, this parameter is picked up in Grid.tsx
4992
- singleClickEdit: true,
4993
- },
4994
4993
  }, {
4995
4994
  editor: GridFormPopoverMenu,
4996
4995
  preventAutoEdit: true,
@@ -5000,10 +4999,7 @@ const GridPopoverMenu = (colDef, custom) => GridCell({
5000
4999
  const GridPopoverMessage = (colDef, props) => GridCell({
5001
5000
  resizable: true,
5002
5001
  ...colDef,
5003
- cellRendererParams: {
5004
- singleClickEdit: true,
5005
- ...colDef.cellRendererParams,
5006
- },
5002
+ singleClickEdit: true,
5007
5003
  }, {
5008
5004
  editor: GridFormMessage,
5009
5005
  ...props,
@@ -5033,6 +5029,7 @@ const GridContextProvider = (props) => {
5033
5029
  const [quickFilter, _setQuickFilter] = useState('');
5034
5030
  const [invisibleColumnIds, _setInvisibleColumnIds] = useState();
5035
5031
  const testId = useRef();
5032
+ const hasExternallySelectedItemsRef = useRef(false);
5036
5033
  const idsBeforeUpdate = useRef([]);
5037
5034
  const prePopupFocusedCell = useRef();
5038
5035
  const [externallySelectedItemsAreInSync, setExternallySelectedItemsAreInSync] = useState(false);
@@ -5096,7 +5093,8 @@ const GridContextProvider = (props) => {
5096
5093
  /**
5097
5094
  * Set the grid api when the grid is ready.
5098
5095
  */
5099
- const setApis = useCallback((gridApi, dataTestId) => {
5096
+ const setApis = useCallback((gridApi, hasExternallySelectedItems, dataTestId) => {
5097
+ hasExternallySelectedItemsRef.current = hasExternallySelectedItems;
5100
5098
  testId.current = dataTestId;
5101
5099
  setGridApi(gridApi);
5102
5100
  gridApi?.setGridOption('quickFilterText', quickFilter);
@@ -5350,10 +5348,17 @@ const GridContextProvider = (props) => {
5350
5348
  externallySelectedItemsAreInSyncRef.current = externallySelectedItemsAreInSync;
5351
5349
  }, [externallySelectedItemsAreInSync]);
5352
5350
  const waitForExternallySelectedItemsToBeInSync = useCallback(async () => {
5351
+ if (!hasExternallySelectedItemsRef.current) {
5352
+ externallySelectedItemsAreInSyncRef.current = true;
5353
+ return;
5354
+ }
5353
5355
  // Wait for up to 5 seconds
5354
5356
  for (let i = 0; i < 5000 / 200 && !externallySelectedItemsAreInSyncRef.current; i++) {
5355
5357
  await wait(200);
5356
5358
  }
5359
+ if (!externallySelectedItemsAreInSyncRef.current) {
5360
+ console.error('externallySelectedItems did not sync with ag-grid selection');
5361
+ }
5357
5362
  }, []);
5358
5363
  const startCellEditing = useCallback(async ({ rowId, colId }) => {
5359
5364
  if (!gridApi)