fix(grid): correct autosize measurement and honour colDataTypeOf - #1309
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 targetsnext-v6rather thanmaster.Why
autosizeColumn()did nothing visible.ValueFilterMode.DeDuplicatemeasured nothing.autoSize.colDataTypeOfwas ignored whenever the grid had data.The docs already describe the fixed behaviour.
autosizeColumn()"runs phase 1 for that column and applies the result", andcolDataTypeOf"forces the data type".Changes
autosizeColumn()applies its result. It computedautoSize.widthPxbut never setcolumn.width. It now sets the width and callsreRenderColumns(), re-rendering rows when the column hasrerenderOnResize. It also creates the measuring canvas whenautosizeColumns()hasn't run yet, instead of falling back to DOM measurement.DeDuplicatemeasures the unique values. It bounded its loop withRowInfo.length, which is never assigned, so the bound wasNaNand the column sized to its header. It now uses the number of unique values. The fallback for browsers withoutObject.keysis removed; it was never reached, and it had its own bug (if (rowsDict)).getColWidth()called the formatter withgetDataItem(i), whereiis the position in that list.RowInfogains an optionalrowIndexArr, whichDeDuplicate,GetGreatestAndSub,GetLongestTextAndSubandGetLongestTextfill 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.colDataTypeOftakes precedence.ContentIntelligentonly guesses the type from row 0 whenautoSize.colDataTypeOfisn't set.Behaviour changes
grid.autosizeColumn(id)now changes the column's width. Callers that used it only to computeautoSize.widthPxwill see the column resize.colDataTypeOfset 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 usesGetGreatestAndSubinstead ofGetLongestText.Validation
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.quirk-autosize-colvaluearray(1/1)example-auto-header-height-autosize(18/18)example15-auto-resize(5/5)example-grid-menu(21/21)tsc --noEmit,eslinton the changed files, andnpm run build:prodare clean.Comments
dist/is not included.🤖 Generated with Claude Code