theme: Fix invisible active/selection backgrounds from double opacity#2512
Merged
Conversation
`Background::opacity` multiplies the existing alpha, but the token clamping passed the absolute target alpha as the factor. When the base color already carried alpha (e.g. `#bfdbfe33` == 0.2 for `table.active.background`), it was attenuated twice (0.2 × 0.2 = 0.04) and the highlight became nearly invisible. Pass a factor (target / base) instead, so the final alpha hits the clamped target regardless of the base alpha, and gradient stops keep their relative opacity. Applied consistently to list_active, table_active, and selection via a shared helper. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The previous `clamp_alpha` derived a single opacity factor from the representative (`from`-stop) color and applied it to the whole `Background`. For a gradient config that left the `to` stop uncapped, and a transparent `from` stop hit the `base == 0` fallback (factor 1.0) so an opaque `to` stop rendered at full alpha — re-introducing the invisible-content regression for custom gradient themes. `Background` no longer exposes its per-stop colors once built, so add `try_parse_background_clamped` to re-derive the background from the raw config value and cap each stop individually. Solid/fallback tokens keep the exact single-factor path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
345f4a7 to
11a282e
Compare
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.
Description
Fixes the Table selection background becoming invisible after #2484.
Background::opacitymultiplies the existing alpha, but the token clamping inThemeColorpassed the absolute target alpha as the multiplier factor. The defaulttable.active.background(#bfdbfe33) already carries0.2alpha, so it was attenuated twice (0.2 × 0.2 = 0.04) and the active row highlight became nearly invisible.The fix passes a factor (
target / base) instead, so the final alpha lands on the clamped target regardless of the base alpha, and gradient stops keep their relative opacity. The same latent bug applied tolist_active(only invisible because components read theHsla, not the token background) andselection(correct only by luck, since its default base alpha is1.0), so all three now go through one sharedclamp_alphahelper.