@linzjs/step-ag-grid 29.11.0 → 29.11.1

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.
@@ -2812,7 +2812,6 @@ const Grid = ({ 'data-testid': dataTestId, defaultPostSort = true, rowSelection
2812
2812
  autoSizeColumns({
2813
2813
  skipHeader,
2814
2814
  userSizedColIds: new Set(userSizedColIds.current.keys()),
2815
- includeFlex: true,
2816
2815
  });
2817
2816
  // Auto-size failed retry later
2818
2817
  if (!autoSizeResult) {
@@ -5344,6 +5343,8 @@ const waitForCondition = async (error, condition, timeoutMs) => {
5344
5343
  return false;
5345
5344
  };
5346
5345
 
5346
+ const colStateId = (colState) => colState.colId;
5347
+ const colStateFlexed = (colState) => !!colState.flex;
5347
5348
  /**
5348
5349
  * Context for AgGrid operations.
5349
5350
  * Make sure you wrap AgGrid in this.
@@ -5625,20 +5626,30 @@ const GridContextProvider = (props) => {
5625
5626
  }, [gridApiOp]);
5626
5627
  /**
5627
5628
  * Resize columns to fit container
5629
+ *
5630
+ * This is used to calculate the preferred size of columns.
5631
+ * It sizes the flex columns first and then clears the calculated width.
5632
+ * If you don't clear flex column widths ag-grid gets confused and does random sizing's.
5633
+ * Then we size the flexed columns.
5628
5634
  */
5629
- const autoSizeColumns = useCallback(({ skipHeader, colIds, userSizedColIds, includeFlex } = {}) => {
5635
+ const autoSizeColumns = useCallback(({ skipHeader, colIds, userSizedColIds } = {}) => {
5630
5636
  if (!gridApi || !gridApi.getColumnState()) {
5631
5637
  return null;
5632
5638
  }
5633
5639
  const colIdsSet = colIds instanceof Set ? colIds : new Set(colIds);
5634
- const colsToResize = gridApi.getColumnState()?.filter?.((colState) => {
5640
+ const colStates = gridApi.getColumnState();
5641
+ const relevantCols = colStates?.filter((colState) => {
5635
5642
  const colId = colState.colId;
5636
- return ((isEmpty(colIdsSet) || colIdsSet.has(colId)) &&
5637
- !userSizedColIds?.has(colId) &&
5638
- (includeFlex || !colState.flex));
5643
+ return (isEmpty(colIdsSet) || colIdsSet.has(colId)) && !userSizedColIds?.has(colId);
5639
5644
  });
5640
- if (!isEmpty(colsToResize)) {
5641
- gridApi.autoSizeColumns(colsToResize.map((colState) => colState.colId), skipHeader);
5645
+ const [flexColumns, nonFlexColumns] = partition(relevantCols, colStateFlexed);
5646
+ // If we don't reset the flex columns auto size it causes issues with random resizing of flex columns
5647
+ if (!isEmpty(flexColumns)) {
5648
+ gridApi.autoSizeColumns(flexColumns.map(colStateId), skipHeader);
5649
+ gridApi.resetColumnState();
5650
+ }
5651
+ if (!isEmpty(nonFlexColumns)) {
5652
+ gridApi.autoSizeColumns(nonFlexColumns.map(colStateId), skipHeader);
5642
5653
  }
5643
5654
  return {
5644
5655
  width: sumBy(gridApi.getColumnState().filter((col) => !col.hide), 'width'),