Skip to content

theme: Fix invisible active/selection backgrounds from double opacity#2512

Merged
madcodelife merged 2 commits into
mainfrom
theme-fix-active-selection-opacity
Jun 25, 2026
Merged

theme: Fix invisible active/selection backgrounds from double opacity#2512
madcodelife merged 2 commits into
mainfrom
theme-fix-active-selection-opacity

Conversation

@obito-t

@obito-t obito-t commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes the Table selection background becoming invisible after #2484. Background::opacity multiplies the existing alpha, but the token clamping in ThemeColor passed the absolute target alpha as the multiplier factor. The default table.active.background (#bfdbfe33) already carries 0.2 alpha, 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 to list_active (only invisible because components read the Hsla, not the token background) and selection (correct only by luck, since its default base alpha is 1.0), so all three now go through one shared clamp_alpha helper.

Before After
image image

obito-t and others added 2 commits June 25, 2026 14:03
`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>
@madcodelife madcodelife force-pushed the theme-fix-active-selection-opacity branch from 345f4a7 to 11a282e Compare June 25, 2026 07:54
@madcodelife madcodelife merged commit ba681df into main Jun 25, 2026
3 checks passed
@madcodelife madcodelife deleted the theme-fix-active-selection-opacity branch June 25, 2026 08:00
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.

2 participants