Skip to content

Make tooltips reachable and keep them in the window, report copies in a status message, and keep a stray drop off the page - #334

Open
r0ny123 wants to merge 15 commits into
ref/integrate-all-20261025from
fix/web-tooltips-and-feedback
Open

r0ny123 wants to merge 15 commits into
ref/integrate-all-20261025from
fix/web-tooltips-and-feedback

Conversation

@r0ny123

@r0ny123 r0ny123 commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Based on ref/integrate-all-20261025, the build of all open PRs (#316's comment has the order), so the diff here is this change alone. One of a set of PRs from a review of the front end against the modern-web-guidance guides; the others are #328, #330 to #333 and the keyboard, semantics and layout PRs. Checked in Chromium.

Tooltips: wrapping, placement and cost (3816c9d). hint.css stays as vendored; the fixes are one block at the end of style.css.

  • Before, a tooltip's text never wrapped, so long ones ran off the window. The cross-compare page was 1120 px wide at 390, 768 and 1024 px, because hidden tooltips still widened it. 15 of its 29 tooltips were cut off even at 1280 px.

  • An idle tooltip is now not laid out at all.

  • Text wraps at min(32rem, 100vw - 2rem).

  • Where the browser has anchor positioning (@supports), a shown tooltip is placed against the window, above or below its element, so a scrolling pane cannot cut it. Phones without it show the tooltip across the bottom of the screen. Older desktop browsers keep hint.css's placement, now wrapped.

  • The same rule removes most of the cost of switching a cross-compare matrix tab. Measured at 100 samples, 1350×940, median/minimum in ms on a loaded machine:

    before after
    layout at load 1021 / 604 461 / 296
    tab click (Event Timing) 1120 / 808 680 / 464
    layout from the click 814 / 406 287 / 159
    layout objects at load 72,886 32,874

    Style time did not change.

  • 59d3b42. The idle rule was [data-hint]:not(:hover):not(:focus-visible)::before/::after, and the rules for a shown tooltip started at :root or used :is(). On a 100×100 cross-compare matrix about 47,000 elements carry a hint, and these selectors topped the load's style work in Chromium's selector timings. The idle state is now [data-hint]::before/::after, the shown state lists :hover and :focus-visible first so that it fails at once on all but one element, and Escape's rule is narrowed the same way.

  • In the dark theme a matrix square drops its dimming filter while hovered. A filter would trap the anchored tooltip inside the square, and it was dimming the tooltip too.

Tooltips: without a mouse (d9da4b5). The score breakdowns, matched families and similar tooltips carry data a keyboard or screen-reader user could not reach.

  • A per-cell tooltip (score cells, matched families, the sample pickers' info icon) is followed by a visually hidden copy of its text, from a new hint_copy macro in links.html. No Tab stop is added per cell.
  • A standalone tooltip ("Total (since queued)", "(whole job)") takes focus, shows itself, and describes its element through aria-describedby. So do the cross-compare order buttons.
  • Triggers get a dotted underline and a help cursor.
  • The end of static/status_message.js puts a tooltip away on Escape (it was static/hints.js until 55779b0), and the pointer can rest on an anchored tooltip.
  • Left as it is: on the matrix, a sighted keyboard user still does not see the byte fractions, which a screen reader reads. The matrix's keyboard access is the keyboard PR's.

A file dropped beside the drop zone (445d1fd, 7806a83).

  • Releasing a dragged file a few pixels off the zone replaced the page with the file: a .smda report opened as JSON, a binary downloaded.
  • upload_form.js now cancels a drag that carries a file everywhere but #myDropzone, with a not-allowed cursor. Dropzone still takes the file on the zone, the drag still opens the overlay, and a text drag is left alone.
  • The guard is installed as the file loads, so it covers both the overlay pages and the query, submit and import pages, where the zone is the page itself. import.html now queues upload_form.js, which does nothing else on that page.

Copying (329f10b).

  • The registration URL's copy was an <i onclick>, not a control, and it confirmed with alert(). On plain HTTP, where navigator.clipboard is undefined, it threw before that. The YARA copy reported both outcomes through alert(), and the clipboard buttons' "Copied!" was a tooltip that nothing announced.
  • A new static/status_message.js provides mcritStatus(): a role="status" region present on every page from load. It is a manual popover where supported and a fixed box otherwise, with a Close button and an automatic hide, and it causes no layout shift. Every copy reports through it.
  • The registration URL is now clipboard_btn(..., label="Copy registration URL"), a real <button type="button">; clipboard_btn gained type="button" and label.
  • Every copy checks for navigator.clipboard and falls back to copying a selection. If that fails too, the text is left selected and the message, which then stays until closed, says to press Ctrl+C.
  • 7d21f1f. Every page carried an inline script that set up the clipboard buttons' tooltips and held the whole report of a copy: the status message, the "Copied!" tooltip and the fallback text. That was about 190 bytes of each gzipped page, none of it needed before the scripts are in.
    • The page keeps copy_to_clipboard(), cut to the part that copies, so a press right after the first paint still copies without a secure context or jQuery.
    • The tooltips and the report are at the end of static/status_message.js (a file of their own, clipboard.js, until b077619), which the copy reaches through whenReady(). A press that comes before the queue has run reports before the tooltip set-up does, so the report creates the button's tooltip if it is not there yet.
  • c6ab20b. status_message.js added its box to <body> once the page had loaded. Bootstrap's legend + * makes the browser restyle the whole page for any element added there, which was a second 300 ms restyle on a 100×100 cross-compare matrix. base.html now carries the empty box and the script fills it, falling back to its own only where it is missing.

Since review was requested.

  • ced475e. The same secret-key race fix as Follow-ups from the batch E review: read-only database, backup command, key file without hard links, upper-case job ids #322: without hard links the key is staged and renamed into place under a lock on the instance folder, so workers cannot end up with different keys.
  • a60b0fc. The test for the status-message script tag matched it exactly, so it failed on a page whose script tags carry a CSP nonce or whose static URLs carry ?v=. It accepts both, and still requires every page to queue status_message.js.
  • 1ac2753. The check that the empty status box comes before <main class="content"> found no such tag as soon as <main> carried another attribute, such as an id. It looks for the start of the tag. The test also moves above the if __name__ == "__main__" block, where unittest never ran it.
  • f35d4bd. A few // comments in the inline script of result_unique_blocks.html went to the browser with every copy of the page. They are Jinja comments now, which are dropped on rendering. testInlineScriptComments.py keeps the count: no template may send more comment lines in its inline scripts than it did before.
  • With the comment and script changes of the other PRs, the sample result page on the build of all PRs is back at 14.1 KB gzipped, from 17.1 KB; the base is 14.1 KB.
  • 72d7da9. The status message tests copy the API token on the settings page. With Harden the response headers, the session cookie and what templates write into scripts #330 the page no longer prints the token, and its copy button stays hidden until Show token is pressed, so the tests timed out on the build of all PRs. They press it first where the page has it. Nothing changes at runtime.
  • b077619. 7d21f1f had put the clipboard tooltips and the report of a copy in clipboard.js, a file queued on every page. Every file the queue holds costs blocking time in Lighthouse's mobile run however little it does: this one took the index page from 17 to 56 ms. The 25 lines now end status_message.js, which every page queues already, and clipboard.js is gone. The index page is at 28 ms against the base's 20, and /data/export at 22 ms against 6.
  • 55779b0. Escape for the tooltips was hints.js, queued on every page for the same cost. Its listener now ends status_message.js, and hints.js is gone with its later() line. On the build of all PRs the index page took 35 to 45 ms against the base's 8 to 15, and /data/export 50 to 57 ms against 5 to 12; with hints.js, icon_titles.js and keyboard.js folded into files the base already queues, the index page is at 10 ms against 15 and /data/export at 14 ms against 5, all 100. AGENTS.md now says a new every-page script goes into an existing every-page file, with the cost.

Tests. Each fix has a test that fails on the base:

  • testBrowserScoreTooltips.py: an idle tooltip takes no room, a shown one is whole inside the window, a hint takes focus, Escape puts it away, and the pointer can rest on it.
  • testResultPages.py: two CI lints, for tooltip room and for no tooltip being reachable only with a mouse.
  • testDropzoneBrowser.py: a file let go beside the zone on the overlay pages and on the three upload pages, a text drag, and a file on the zone.
  • New testStatusMessages.py (8 CI lints) and testStatusMessageBrowser.py (5), and two YARA tests in testBrowser.py.
    • testStatusMessages.py holds that every page queues status_message.js and not clipboard.js (b077619), and that hints.js is gone and its Escape listener is in status_message.js (55779b0).
    • testStatusMessageBrowser.py presses Show token before it copies the API token (72d7da9).
  • The script lists in testDeferredJqueryBrowser.py, testJavascriptScoping.py and testParseTimeScripts.py include the one new queued file, status_message.js.
  • testInlineScriptComments.py is new (f35d4bd).
  • testSecretKeyRace.py replaces the test that pinned the old create-then-lock order with two that pin the new one (ced475e).

Runs:

  • 33 related modules: 1502 passed, with two failures then fixed in their commits; testDeferredJqueryBrowser and testDropzoneBrowser then passed 83/83.
  • 23 modules that render the touched templates: 609 passed.
  • testAutocompleteEscaping and testUniqueBlocks: 78 passed.
  • After 7806a83: testDropzoneBrowser.py passed 10/10.

ruff is clean.

Lighthouse. Accessibility, Best Practices and SEO are 100 on the nine pages measured, with CLS 0. Desktop Performance is 100 apart from ?famid=1 at 95. Mobile was measured on a machine at a load average of 15 to 24, where the base and this branch swung alike. Both get a run on a quiet machine, recorded in the merge-order comment on #316.

hint.css kept every tooltip laid out while hiding it, and wrote its text on
one line. A long hint widened the cross compare pages to 1120px in any
narrower window, the "Total (since queued)" hint ran off a phone's screen,
the matrix pane cut off the top of the tooltips on its first rows, and the
two hidden boxes behind each matrix square were most of the time a large
matrix took to lay out.

style.css now gives an idle hint no box at all, wraps the text at a width
that fits the window, and, where anchor positioning is supported, places a
shown tooltip against the window above or below its element, wherever it
fits. A phone without anchor positioning shows it at the foot of the
window. The browser tests hover every tooltip of the cross compare and a
result page at three widths; a lint over style.css keeps the rules in CI.
hint.css shows a tooltip on hover or focus, but no element with one could
take the focus, so the byte counts behind each score, a sample's details in
the pickers, the families an aggregated function matched and what "Total
(since queued)" measures were there for a pointer and nobody else. Escape
did not put a tooltip away, and moving the pointer onto one closed it.

A tooltip in a table cell is now followed by a visually hidden copy of its
text, which a screen reader reads with the cell, rather than adding a Tab
stop to every cell. The few that stand alone take the focus and are
described by their text. Tooltip triggers are underlined with dots, a new
static/hints.js puts a tooltip away on Escape, and an anchored tooltip
touches its element and takes the pointer, so it stays open while read.
The drop overlay opens under the pointer on the first drag, and only the
zone took a file: let go a little off it and the browser opened the file
in place of the page, or downloaded it. The overlay's dragover handler now
cancels a drag that carries a file anywhere but on the zone, with a drop
effect of none, and a drop listener cancels such a drop, so the page stays.
Dropzone's own handlers still take the file on the zone and stop the
events there, and a drag of text is left alone.
The YARA rule and the registration URL answered a copy with alert(), which
takes the focus and holds the page until it is answered, and the clipboard
buttons only with a "Copied!" tooltip, which a screen reader is not told
about. The registration URL was copied by an <i onclick> that no keyboard
reached and no screen reader saw, and both it and the clipboard buttons
called navigator.clipboard, which a page served over plain HTTP does not
have, so there they threw and said nothing.

A new static/status_message.js puts a role="status" region on every page
from the start: a manual popover where the browser has them, otherwise a
fixed box, so it moves nothing. The clipboard buttons, the YARA copy and
the registration URL, which is now a clipboard button of its own name,
report through it. They check for navigator.clipboard and fall back to a
copy of a selection; where that fails too, the text is left selected and
the message, which then stays until closed, says to press Ctrl+C.
The guard that cancels a file drag outside the drop zone only ran where
the drop overlay is, so on the pages whose content is the zone a file
let go beside it was opened in the tab. The guard now installs when
upload_form.js loads, before any form check, and the import page, which
had no such script, queues it too.
The test matched the script tag exactly, so it failed on a page whose script tags carry
a CSP nonce or whose static URLs carry a ?v= version. It now accepts both, and still
requires every page to queue status_message.js.
The idle rule was [data-hint]:not(:hover):not(:focus-visible)::before/::after, and the
rules for a shown tooltip started at :root or used :is(). On a 100 by 100 cross compare
matrix about 47,000 elements carry a hint, and Chromium's selector timings put these at
the top of the load's style work. The idle state is now [data-hint]::before/::after, the
shown state is listed with :hover and :focus-visible first so that it fails at once on
all but one element, and Escape's rule is narrowed the same way.
status_message.js added its box to <body> once the page had loaded. Bootstrap's
`legend + *` makes the browser restyle the whole page for any element added there, which
was a second 300 ms restyle on a 100 by 100 cross compare matrix. base.html now carries
the empty box and the script fills it, falling back to its own only where it is missing.
Without hard links the key was written into a file created with O_EXCL,
empty until filled. A worker that opened that file in the gap could
replace it and find the creator's key still written into the file it
had displaced; a third worker that had opened the displaced file before
the replacement then read the loser's key and used it, while everyone
else used the winner's. One round in about 1600 ended that way.

The staged key, complete and private from mkstemp, is now renamed into
place under a lock on the instance folder, looking at the key file again
once the lock is held. No key file is opened for writing any more, and
none is ever visible unfinished.

The test that pinned the old create-then-lock order is replaced by two
that pin the new one.
The check that the empty status message box comes before <main class="content">
found no such tag as soon as <main> carries another attribute, such as an id.
It now looks for the start of the tag. The test also moves above the
`if __name__ == "__main__"` block, where it was never run by unittest.
Every page carried an inline script that set up the clipboard buttons' tooltips
and held the whole report of a copy: the status message, the "Copied!" tooltip
and the fallback text. About 190 bytes of each gzipped page, and none of it is
needed before the scripts are in.

The page keeps copy_to_clipboard(), cut to the part that copies, so that a press
right after the first paint still copies without a secure context or jQuery.
The tooltips and the report moved to clipboard.js, queued after
status_message.js, which the copy reaches through whenReady(). A press that
comes before the queue has run reports before the tooltip set-up does, so the
report creates the button's tooltip if it is not there yet.
A few // comments inside inline scripts of templates went to the browser with
every copy of the page, where a Jinja comment says the same to whoever reads the
template and is dropped on rendering. They are Jinja comments now.

A ratchet test keeps the count: no template may send more comment lines in its
inline scripts than it did before.
The status message tests copy the API token on the settings page. With #330
the page no longer prints the token: its copy button stays hidden until Show
token is pressed, so the tests timed out on the build of all PRs. They press it
first where the page has it.
7d21f1f moved the clipboard buttons' tooltips and the report of a copy out of
every page into clipboard.js, queued on every page. Each file the queue adds is
one more ordered request before the page's scripts have run, and Lighthouse's
mobile run of the index page went from about 17 ms of blocking time to 56 ms
with it, median of six runs against the commit before.

The 25 lines go at the end of status_message.js, which they use and which every
page queues already. The index page is back at 28 ms against the base's 20, and
/data/export at 22 ms against 6. The page is as small as with clipboard.js.
Escape for the hint.css tooltips was hints.js, queued on every page. Each file the
queue adds is one more ordered request before the page's scripts have run, and in
Lighthouse's mobile run it costs blocking time however little it does. On the build
of all the pull requests the index page took 35 to 45 ms against the base's 8 to 15,
and /data/export 50 to 57 ms against 5 to 12. With hints.js, icon_titles.js and
keyboard.js folded into files the base already queues, the index page is at 10 ms
against 15 and /data/export at 14 ms against 5, all 100.

The listener goes at the end of status_message.js, which every page queues already
and which loads right after hints.js did, with nothing queued between them. hints.js
is gone, with its later() line. AGENTS.md says a new every-page script goes into an
existing every-page file, with the cost.
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