Skip to content

Rework frozen column shadow#3969

Merged
nstepien merged 10 commits into
mainfrom
frozenshadow
Mar 2, 2026
Merged

Rework frozen column shadow#3969
nstepien merged 10 commits into
mainfrom
frozenshadow

Conversation

@nstepien
Copy link
Copy Markdown
Collaborator

@nstepien nstepien commented Feb 22, 2026

Before

Borders would increase the layer size (in devtools: "show layer borders"), and bleed onto other rows. They'd also be slightly round, instead of being uniform vertically. box-shadow may also impact browser rendering performance, haven't checked though.
I've maxed out the shadow's color opacity in the second screenshot so it's easier to tell.

image image

After

No overlapping layers, uniform shadows, and thanks to container queries: no shadow if we're at scrollable: inline-start 👍
I've also tweaked the shadow so it looks more like a shadow than before.

image image image

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Feb 27, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.55%. Comparing base (da265d3) to head (a796ed6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3969      +/-   ##
==========================================
+ Coverage   97.53%   97.55%   +0.01%     
==========================================
  Files          36       36              
  Lines        1463     1473      +10     
  Branches      472      481       +9     
==========================================
+ Hits         1427     1437      +10     
  Misses         36       36              
Files with missing lines Coverage Δ
src/DataGrid.tsx 99.00% <100.00%> (+0.02%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/style/core.ts
transition: opacity 0.1s;

/* TODO: reverse 'opacity' and remove 'not' */
@container rdg-root not scroll-state(scrollable: inline-start) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Firefox/Safari will always show the shadow until they support scroll-state container queries.
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/container-type

Comment thread src/style/core.ts
Comment on lines +97 to +102
width: 10px;
background-image: linear-gradient(
to right,
light-dark(rgb(0 0 0 / 15%), rgb(0 0 0 / 40%)),
transparent
);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shadow is wider/stronger than before, let me know if you think we should tweak it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread src/DataGrid.tsx
)}
</DataGridDefaultRenderersContext>

{lastFrozenColumnIndex > -1 && (
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the best way I found to make it work in all scenarios, including column grouping.

@nstepien nstepien marked this pull request as ready for review February 27, 2026 19:30
Comment thread src/style/core.ts
Comment on lines +97 to +102
width: 10px;
background-image: linear-gradient(
to right,
light-dark(rgb(0 0 0 / 15%), rgb(0 0 0 / 40%)),
transparent
);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread src/style/core.ts
transition: opacity 0.1s;

/* TODO: reverse 'opacity' and remove 'not' */
@container rdg-root not scroll-state(scrollable: inline-start) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great

Comment thread src/DataGrid.tsx

{lastFrozenColumnIndex > -1 && (
<>
<div
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is is possible or a good idea to use a single div instead? Can it cause performance issues?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, for example:

| header cell |
| top summary |
|    cell     |
|             |
| bot summary |

If we have no rows between the last row and the bottom summary, then we don't want to render a shadow for non-existent cells.

Also, if you scroll very fast then rows/cells may not be rendered yet, in that case I think it's better to not render the shadow as well.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense.

@nstepien nstepien enabled auto-merge (squash) March 2, 2026 19:41
@nstepien nstepien merged commit 26c96ee into main Mar 2, 2026
2 checks passed
@nstepien nstepien deleted the frozenshadow branch March 2, 2026 19:45
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.

3 participants