Repository navigation
fix(cdk/table): collapse table borders when a fixed layout is used - #34150
Open
vurumalla92 wants to merge 1 commit into
Open
vurumalla92 wants to merge 1 commit into
vurumalla92 wants to merge 1 commit into
Conversation
PR angular#33439 baked in option 1 from angular#32715 (overflow-anchor: none), but option 2's border-collapse half was never applied: nothing in the CDK or Material table styles sets border-collapse, so the table keeps the separate border model while rows are swapped in and out during virtual scrolling. The resulting height fluctuations throw off the scroll calculations and the content jumps around, as still reported on Angular/CDK 22.0.5 (Firefox). A fixed layout is already forced on whenever virtual scrolling is enabled (see fixedLayout in table.ts), so collapsing the borders on the fixed-layout rules covers both cdk-table (.cdk-table-fixed-layout) and mat-table (.mat-table-fixed-layout, which has its own copy of the rule because the CDK stylesheet is not loaded for Material tables). Fixes angular#32715.
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Author
|
Friendly ping — this PR is waiting on the Google-internal presubmit (google-internal-tests) and pullapprove, plus the missing |
This branch has not been deployed
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.
Fixes #32715.
PR #33439 baked in option 1 from @Fichti1982's workaround in #32715 (
overflow-anchor: noneon the virtual scroll viewport), but option 2 was only half applied: a fixed layout is forced on when virtual scrolling is enabled (fixedLayoutinsrc/cdk/table/table.ts), yet nothing in the CDK or Material table styles setborder-collapse. The table therefore keeps the separate border model while rows are swapped in and out during virtual scrolling, so the table height fluctuates and throws off the scroll calculations — the jumping/shifting still reported on Angular/CDK 22.0.5 (Firefox).This change adds
border-collapse: collapseto the fixed-layout rules, which is exactly the rule a fixed layout is forced on for when virtual scrolling is enabled:src/cdk/table/table.scss—.cdk-table-fixed-layout(coverscdk-table)src/material/table/table.scss—.mat-table-fixed-layout(coversmat-table, which carries its own copy of the rule because the CDK stylesheet is not loaded for Material tables)Both are one-line additions with a comment explaining why. Material rows only use bottom borders, so collapsing the border model does not change the rendered row separators; it only stops the box-model fluctuations that disturb the virtual scroll math. The docs
table-virtual-scrollexample (sticky header,itemSize="52") is the affected scenario.Tests
src/cdk/table/table.spec.ts: new testshould collapse borders on tables with virtual scrollingassertsgetComputedStyle(table).borderCollapseis'collapse'for a table inside acdk-virtual-scroll-viewport.src/material/table/table.spec.ts: new testshould collapse borders on tables with a fixed layout(with a new minimalMatTableFixedLayoutAppfixture) asserts the same for amat-tablewith[fixedLayout]="true".Verification
border-collapse: collapsein the fixed-layout rules. Negative control: compiling the pre-fix stylesheets emits onlytable-layout: fixed(noborder-collapse, so the computed value stays the defaultseparateand the new tests fail without this fix).Caveats — not verified here