Skip to content

fix(grid): correct autosize measurement and honour colDataTypeOf - #1309

Merged
6pac merged 1 commit into
next-v6from
fix/autosize-measurement
Sep 30, 2026
Merged

6pac merged 1 commit into
next-v6from
fix/autosize-measurement

Conversation

@6pac-ai

@6pac-ai 6pac-ai commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fixes four faults in the grid's content autosizing (autosizeColumns() / column.autoSize). Two of them change behaviour that code may rely on, so this targets next-v6 rather than master.

Why

  • autosizeColumn() did nothing visible.
  • ValueFilterMode.DeDuplicate measured nothing.
  • A formatter that reads other fields of its row was measured against the wrong row.
  • A type supplied through autoSize.colDataTypeOf was ignored whenever the grid had data.

The docs already describe the fixed behaviour. autosizeColumn() "runs phase 1 for that column and applies the result", and colDataTypeOf "forces the data type".

Changes

  1. autosizeColumn() applies its result. It computed autoSize.widthPx but never set column.width. It now sets the width and calls reRenderColumns(), re-rendering rows when the column has rerenderOnResize. It also creates the measuring canvas when autosizeColumns() hasn't run yet, instead of falling back to DOM measurement.
  2. DeDuplicate measures the unique values. It bounded its loop with RowInfo.length, which is never assigned, so the bound was NaN and the column sized to its header. It now uses the number of unique values. The fallback for browsers without Object.keys is removed; it was never reached, and it had its own bug (if (rowsDict)).
  3. The formatter gets the source row. Once a value filter reduces the rows to a short value list, getColWidth() called the formatter with getDataItem(i), where i is the position in that list. RowInfo gains an optional rowIndexArr, which DeDuplicate, GetGreatestAndSub, GetLongestTextAndSub and GetLongestText fill in, so the formatter receives the row and data item the value came from. The longest/greatest searches now start from the first selected row rather than row 0.
  4. colDataTypeOf takes precedence. ContentIntelligent only guesses the type from row 0 when autoSize.colDataTypeOf isn't set.

Behaviour changes

  • grid.autosizeColumn(id) now changes the column's width. Callers that used it only to compute autoSize.widthPx will see the column resize.
  • Columns with colDataTypeOf set now use the strategy for that type even when row 0 suggests another type. For example, a 'number' column whose row 0 holds a string now uses GetGreatestAndSub instead of GetLongestText.

Validation

  • New self-hosting spec cypress/e2e/quirk-autosize-measurement.cy.ts, one test per fix. With the source fix reverted, all four tests fail, each on the assertion it targets. With the fix, all four pass.
  • These related specs pass on this branch:
    • quirk-autosize-colvaluearray (1/1)
    • example-auto-header-height-autosize (18/18)
    • example15-auto-resize (5/5)
    • example-grid-menu (21/21)
  • tsc --noEmit, eslint on the changed files, and npm run build:prod are clean.
  • The full Cypress suite was not run locally; CI covers it.

Comments

dist/ is not included.

🤖 Generated with Claude Code

…des and supplied types

- autosizeColumn() computed autoSize.widthPx but never applied it; it now
  sets the column width and re-renders the columns
- ValueFilterMode.DeDuplicate bounded its loop with the never-assigned
  RowInfo.length, so nothing was measured; it now uses the unique value count
- when a value filter reduces rows to a value list, the formatter received
  getDataItem() of the list position rather than of the source row; RowInfo
  now carries rowIndexArr so the formatter gets the row the value came from
- ContentIntelligent guessed the data type from row 0 even when
  autoSize.colDataTypeOf was set; the supplied type now takes precedence

Adds cypress/e2e/quirk-autosize-measurement.cy.ts, which fails on the
unfixed code and passes with the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@6pac
6pac merged commit 801c00a into next-v6 Sep 30, 2026
3 checks passed
@6pac
6pac deleted the fix/autosize-measurement branch September 30, 2026 06:19
6pac-ai added a commit that referenced this pull request Oct 2, 2026
Brings in #1309 (autosize measurement fixes). One conflict, in
getColWidth(): this branch had a blank line where #1309 adds the row lookup
for the value being measured. The line from next-v6 is kept.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants