fix: table header background ignores container-level dark mode - #4765
Draft
ernst-dev wants to merge 1 commit into
Draft
fix: table header background ignores container-level dark mode#4765ernst-dev wants to merge 1 commit into
ernst-dev wants to merge 1 commit into
Conversation
When .awsui-dark-mode is applied to a container ancestor rather than <body>, the sticky table header and thead background-color token (color-background-table-header) was not updating to the dark value. Root cause: the design token CSS custom properties are defined inside @layer awsui-base-theme { body { ... } }. The dark-mode override block is also nested inside this body rule, so the token value is set on the .awsui-dark-mode element. While CSS custom properties cascade, the @layer specificity means that an explicit dark-mode-only rule in the component SCSS is needed to guarantee the correct token resolution when dark mode is scoped to a container. Fix: use the dark-mode-only() mixin (from internal/styles/utils/theming) in src/table/styles.scss and src/table/header-cell/styles.scss to re-declare the background property inside the dark-mode selector. This generates a .awsui-dark-mode .header-secondary and .awsui-dark-mode .header-cell rule that correctly wins the cascade for container-level dark mode. Affected elements: - .header-secondary (sticky header wrapper div) - .header-cell (thead <th> cells) - .header-cell.sticky-cell (sticky column header cells) - full-page variant backgrounds Dev page: pages/table/dark-mode-container.page.tsx Regression test for container-level dark mode with stickyHeader and stickyColumns. Fixes #4111
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 #4111
When
.awsui-dark-modeis applied to a container ancestor rather than<body>, the sticky table header and<thead>background-color were not updating to the dark value — they showed the light fallback (#fafafa) instead.Root cause
The design token CSS custom properties are defined inside
@layer awsui-base-theme { body { ... } }. The dark-mode override block is also nested inside thisbodyrule, so the token override is set on the.awsui-dark-modeelement. While CSS custom properties cascade, the@layerinteraction with unlayered component styles means an explicitdark-mode-onlyrule is needed in the component SCSS to guarantee correct token resolution when dark mode is scoped to a container.Fix
Use the
dark-mode-only()mixin (frominternal/styles/utils/theming) in:src/table/styles.scss— for.header-secondary(the sticky header wrapper div)src/table/header-cell/styles.scss— for.header-cell,.header-cell.sticky-cell, and full-page variant backgroundsThis generates
.awsui-dark-mode .header-secondaryand.awsui-dark-mode .header-cellrules that correctly win the cascade for container-level dark mode.Dev page
Added
pages/table/dark-mode-container.page.tsxas a regression test page showing:.awsui-dark-modecontainer div (the failing scenario).awsui-dark-modecontainer divTesting
npm run build)gulp test:unit)