Skip to content

fix(html): the pdf's selection keeps its background - #910

Merged
andiwand merged 2 commits into
mainfrom
fix/selection-keeps-its-background
Sep 20, 2026
Merged

andiwand merged 2 commits into
mainfrom
fix/selection-keeps-its-background

Conversation

@andiwand

Copy link
Copy Markdown
Member

Follow-up to #907, which went one step too far: the ::selection rules it added state a colour and no background, and an author ::selection rule drops the UA's own background. So a selection in a pdf view painted nothing at all - no glyphs, which was the point, but no highlight either. Reported from the device: "no selection background nothing", and with no visible selection there is nothing to aim a mark at.

The rules now state the background with the colour, as Highlight, so it follows the platform.

Checked

Five variants of the rule in chromium, one row each, all selected at once:

rule background hidden layer
none painted shows
color:transparent gone hidden
-webkit-text-fill-color:transparent painted shows
color:transparent;background:Highlight painted hidden
color:transparent;background-color:rgba(...) painted hidden

Only the last two do both, and Highlight is the one that is not a hardcoded colour.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FJJdfqpnVCKBNHXjAVxSou

The `::selection` rules that keep the hidden text layer hidden stated a
colour and no background. An author `::selection` rule drops the UA's own
background, so a selection in a pdf view painted nothing at all: no
glyphs, which was the point, but no highlight either, and a reader
selecting text saw no selection to aim a mark at.

The rules now state the background with the colour, as `Highlight`, which
follows the platform rather than fixing a colour of its own.

Checked in chromium against five variants of the rule: the colour alone
takes the background with it, `-webkit-text-fill-color` does not hide the
layer at all, and stating both does what is wanted.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FJJdfqpnVCKBNHXjAVxSou
@andiwand
andiwand force-pushed the fix/selection-keeps-its-background branch from 3e9e649 to 55876ba Compare September 20, 2026 09:41
…e comments

A highlight pseudo takes `background-color`; the `background` shorthand also
carries longhands the pseudo does not, which a strict engine may drop whole.
The two entries in `Unreleased` describe one change nothing has released, so
they read as one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0149gFxhkvKTBQidz6brU8Vt
@andiwand
andiwand merged commit 1968633 into main Sep 20, 2026
17 checks passed
@andiwand
andiwand deleted the fix/selection-keeps-its-background branch September 20, 2026 09: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.

1 participant