Repository navigation
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
Conversation
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.
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.
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.cssstays as vendored; the fixes are one block at the end ofstyle.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 keephint.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:
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:rootor 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:hoverand:focus-visiblefirst 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.
hint_copymacro inlinks.html. No Tab stop is added per cell.aria-describedby. So do the cross-compare order buttons.static/status_message.jsputs a tooltip away on Escape (it wasstatic/hints.jsuntil 55779b0), and the pointer can rest on an anchored tooltip.A file dropped beside the drop zone (445d1fd, 7806a83).
.smdareport opened as JSON, a binary downloaded.upload_form.jsnow 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.import.htmlnow queuesupload_form.js, which does nothing else on that page.Copying (329f10b).
<i onclick>, not a control, and it confirmed withalert(). On plain HTTP, wherenavigator.clipboardis undefined, it threw before that. The YARA copy reported both outcomes throughalert(), and the clipboard buttons' "Copied!" was a tooltip that nothing announced.static/status_message.jsprovidesmcritStatus(): arole="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.clipboard_btn(..., label="Copy registration URL"), a real<button type="button">;clipboard_btngainedtype="button"andlabel.navigator.clipboardand 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.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.static/status_message.js(a file of their own,clipboard.js, until b077619), which the copy reaches throughwhenReady(). 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.status_message.jsadded its box to<body>once the page had loaded. Bootstrap'slegend + *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.htmlnow carries the empty box and the script fills it, falling back to its own only where it is missing.Since review was requested.
?v=. It accepts both, and still requires every page to queuestatus_message.js.<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 theif __name__ == "__main__"block, where unittest never ran it.//comments in the inline script ofresult_unique_blocks.htmlwent to the browser with every copy of the page. They are Jinja comments now, which are dropped on rendering.testInlineScriptComments.pykeeps the count: no template may send more comment lines in its inline scripts than it did before.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 endstatus_message.js, which every page queues already, andclipboard.jsis gone. The index page is at 28 ms against the base's 20, and/data/exportat 22 ms against 6.hints.js, queued on every page for the same cost. Its listener now endsstatus_message.js, andhints.jsis gone with itslater()line. On the build of all PRs the index page took 35 to 45 ms against the base's 8 to 15, and/data/export50 to 57 ms against 5 to 12; withhints.js,icon_titles.jsandkeyboard.jsfolded into files the base already queues, the index page is at 10 ms against 15 and/data/exportat 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.testStatusMessages.py(8 CI lints) andtestStatusMessageBrowser.py(5), and two YARA tests intestBrowser.py.testStatusMessages.pyholds that every page queuesstatus_message.jsand notclipboard.js(b077619), and thathints.jsis gone and its Escape listener is instatus_message.js(55779b0).testStatusMessageBrowser.pypresses Show token before it copies the API token (72d7da9).testDeferredJqueryBrowser.py,testJavascriptScoping.pyandtestParseTimeScripts.pyinclude the one new queued file,status_message.js.testInlineScriptComments.pyis new (f35d4bd).testSecretKeyRace.pyreplaces the test that pinned the old create-then-lock order with two that pin the new one (ced475e).Runs:
testDeferredJqueryBrowserandtestDropzoneBrowserthen passed 83/83.testAutocompleteEscapingandtestUniqueBlocks: 78 passed.testDropzoneBrowser.pypassed 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=1at 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.