Menus, submenus, tooltips, rich tooltips and the FAB menu held their exit with `transition-behavior: allow-discrete` on `display` and `overlay`. Firefox transitions neither (MDN browser-compat-data, `display.is_transitionable`: Chrome 117, Safari 18, Firefox none), so every one of them vanished on its first frame there. A script cannot hold a popover open instead: `beforetoggle` is not cancellable on the way out, and the browser's own light dismiss (Escape, a press outside) never asks. resources/js/popover-exit.js: a popover marked `data-md-popover-exit` closes for real at once — focus, aria-expanded and toggle stay the browser's — and a copy taken in `beforetoggle`, while it is still drawn, stands in for the exit. The copy is decoration: a manual popover in the top layer (closing no other popover), inert, aria-hidden, without ids or nested popovers, `x-ignore`d so Alpine starts nothing in it, pinned to the popover's box with its resolved colours. It is shown with its transitions off, so `@starting-style` does not replay the entry, then marked `data-md-popover-closing`, which each stylesheet turns into its closed values (`:popover-open:not([data-md-popover-closing])`, and the FAB menu's items' sink), so it moves on the component's own tokens. It is removed once the longest of them has run, and opening the popover again takes it away. Under reduced motion every duration is zero and no copy is made. `display`, `overlay` and `allow-discrete` leave the transitions, so Chrome and Safari take the same path. Browser tests in Chrome, Firefox and Safari slow the motion tokens so a round trip still finds the exit on screen: a menu after Escape and after a press outside (the real menu closed and focus back on its button, the copy inert, fading, with no Alpine state, and gone after), a reopen part-way through, reduced motion, a submenu while its menu stays open, a tooltip, the FAB menu's items part-way down their sink, and a persistent rich tooltip. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
81 lines
2.9 KiB
CSS
81 lines
2.9 KiB
CSS
/*
|
|
* <x-tooltip>: M3's plain tooltip, a short label for a control in the inverse surface.
|
|
*
|
|
* The bubble is a `popover="manual"` in the top layer, so no `overflow: hidden` parent clips it,
|
|
* placed by CSS anchor positioning on its `data-md-side` and flipping to the other side where the
|
|
* window has no room. PlainTooltipTokens and TooltipDefaults (androidx Compose Material 3,
|
|
* Apache-2.0): `inverse-surface` container with the extra-small corner, `body-small` supporting
|
|
* text in `inverse-on-surface`, 8px either side and 4px above and below, 200px wide at most, 4px
|
|
* from its anchor. It never takes the pointer, so it can stand over the control it names.
|
|
*
|
|
* It fades in and out on the fast effects spring: `@starting-style` gives the fade in a start, and
|
|
* the fade out is its exit copy's (`data-md-popover-exit`, resources/js/popover-exit.js), which
|
|
* `data-md-popover-closing` turns back to the closed opacity. resources/js/tooltip.js shows and
|
|
* hides it.
|
|
*/
|
|
|
|
@layer material.reset, material.tokens, material.base, material.layout, material.components, material.text, material.visibility;
|
|
|
|
@layer material.components {
|
|
[data-md-tooltip-anchor] {
|
|
display: inline-flex;
|
|
}
|
|
|
|
[data-md-tooltip] {
|
|
inset: auto;
|
|
margin: 0;
|
|
max-inline-size: 200px;
|
|
overflow: visible;
|
|
border-width: 0;
|
|
border-radius: var(--md-sys-shape-corner-xs);
|
|
padding-block: var(--md-sys-measurement-space50);
|
|
padding-inline: var(--md-sys-measurement-space100);
|
|
background-color: var(--md-sys-color-inverse-surface);
|
|
color: var(--md-sys-color-inverse-on-surface);
|
|
font: var(--md-sys-typescale-body-sm);
|
|
letter-spacing: var(--md-sys-typescale-body-sm-tracking);
|
|
font-variation-settings: normal;
|
|
text-align: center;
|
|
white-space: normal;
|
|
pointer-events: none;
|
|
opacity: 0;
|
|
transition-property: opacity;
|
|
transition-duration: var(--md-sys-motion-effects-fast-duration);
|
|
transition-timing-function: var(--md-sys-motion-effects-fast);
|
|
|
|
&:popover-open:not([data-md-popover-closing]) {
|
|
opacity: 1;
|
|
|
|
@starting-style {
|
|
opacity: 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
[data-md-tooltip]:is([data-md-side='top'], [data-md-side='bottom']) {
|
|
margin-block: var(--md-sys-measurement-space50);
|
|
position-try-fallbacks: flip-block;
|
|
}
|
|
|
|
[data-md-tooltip]:is([data-md-side='left'], [data-md-side='right']) {
|
|
margin-inline: var(--md-sys-measurement-space50);
|
|
position-try-fallbacks: flip-inline;
|
|
}
|
|
|
|
[data-md-tooltip][data-md-side='top'] {
|
|
position-area: top;
|
|
}
|
|
|
|
[data-md-tooltip][data-md-side='bottom'] {
|
|
position-area: bottom;
|
|
}
|
|
|
|
[data-md-tooltip][data-md-side='left'] {
|
|
position-area: left;
|
|
}
|
|
|
|
[data-md-tooltip][data-md-side='right'] {
|
|
position-area: right;
|
|
}
|
|
}
|