Show no tooltip on the control a sheet or dialog focuses as it opens

A modal side sheet, bottom sheet and the modal rail move the focus to
their first control as they open (x-trap), and `<x-modal>` does in
`showModal()`. On a page loaded with the sheet already open (a
`wire:model` set from `?workout=` in the URL) the browsers count that
focus as `:focus-visible`, and so they do for a sheet or dialog opened
from the keyboard, so tooltip.js showed the close button's "Close"
tooltip the moment the layer appeared, over its title, with no keyboard
use. Confirmed in Chrome, Firefox and Safari for the deep-linked sheet
and a full-screen dialog opened with Enter; a deep-linked `<x-modal>`'s
own focus was not counted as keyboard focus. M3 lets a tooltip appear
on hover or focus and says nothing that asks for one on a focus the
component moves itself.

layers.js gains `openingFocus(event)`: a focus is a modal layer's own
when the nearest open dialog, `aria-modal` panel or modal rail around
its target is entered from outside it, or from nowhere, and no Tab is
moving it (a Tab moves the focus while its keydown is handled, by the
browser or by focus-trap wrapping round the panel). tooltip.js and
rich-tooltip.js leave such a focus out; focus moved within the layer,
a Tab onto the control and a focus returned to it from a menu inside
still show the tooltip. The docblocks, the skill and UPGRADE.md say so.

A browser test loads a page with a modal sheet open at 393px, opens a
full-screen dialog and a dialog whose first control is a rich tooltip's
trigger from the keyboard, and checks that no tooltip is up on the
focused control, then that Tab wrapping round to the close button shows
its tooltip; it fails without the change in Chrome, Firefox and Safari,
each part on its own.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Andreas Reinhold / reini
2026-09-17 07:16:32 +02:00
co-authored by Claude Opus 5
parent 16c52d46e9
commit b62c83f244
8 changed files with 170 additions and 8 deletions
+9
View File
@@ -91,6 +91,15 @@
around the field, which fills its container, so from `medium`, where the field stops at 40rem,
the list ran on past the field's end across the whole container. The field itself is the anchor
now, and the wrapper `<div>` is gone; the list keeps hanging under the field's supporting text.
- **A sheet or dialog that opens shows no tooltip on the control it focuses.** A modal
`<x-drawer>`, `<x-bottom-sheet>`, the modal rail and `<x-modal>` move the focus to their first
control as they open, and on a page loaded with the sheet open (`wire:model` already set, say
from `?workout=` in the URL) or a layer opened from the keyboard, browsers count that focus as
keyboard focus: the close button's plain tooltip stood over the sheet the moment it appeared, in
Chrome, Firefox and Safari. Plain and rich tooltips now leave out focus a modal layer moves into
itself from outside; a Tab onto the control, including the one that wraps round to it, and focus
moved within the layer still show them. An `autofocus` an application put on another control to
keep the focus off the close button can go.
## From 2.0.0 to 2.1.0