Repository navigation
feat(overlay)!: use native dialog and popover for dialogs and tooltips - #33
Merged
Merged
Conversation
OverlayModal, OverlayDrawer and OverlayConfirm are native <dialog>s opened with showModal(). OverlayTooltip and v-tooltip are native popovers placed by CSS anchor positioning. vue-afloat is no longer a dependency. BREAKING CHANGE: the dialogs drop their `to` prop (they render in place in the top layer), `styles/vue-afloat.css` is replaced by `styles/tooltip.css` and `styles/dialog.css`, and the vue-afloat peer dependency is removed.
# Conflicts: # packages/design/README.md
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.
Summary
The dialogs (
OverlayModal,OverlayDrawer,OverlayConfirm) and tooltips (OverlayTooltip,v-tooltip) now use browser features instead of JS libraries. Before, the dialogs used reka-ui'sDialog(JS focus trap, Teleport,usePortalTarget) and the tooltips used vue-afloat (floating-ui + Teleport).Dialogs are native
<dialog>s opened withshowModal(). The browser provides the top layer, the focus trap, the inert page and Esc-to-close.commandfor+command="show-modal" | "close"). Where those are missing, a click fallback is wired.closedby="any"closes the dialog on a backdrop click, with a small JS fallback.OverlayConfirmis arole="alertdialog"withclosedby="closerequest", so Esc cancels it but a backdrop click doesn't.@starting-styleplusdisplay/overlaytransitions withallow-discrete.useNativeDialog(composables/dialog.ts).Tooltips are
[popover]elements placed by CSS anchor positioning (position-area+position-try-fallbacksto flip at viewport edges).popover="hint"where supported, andmanualplus our own Esc handling elsewhere.interestforships outside Chromium.v-tooltipis our own small directive now. It appends the tooltip to the trigger's root node (the document body or the enclosing shadow root) and copies thedark/lightscheme class.bindTooltip/vTooltip(composables/tooltip.ts).Because the top layer renders in place, these overlays no longer teleport. They can't escape a shadow root and need no z-index layers.
Why not depend on ui-sdk:
@ui-sdk/core0.1.0-beta.6 usespopover="manual"only to reach the top layer, then implements focus trap, inert and positioning in JS. It never callsshowModal()and doesn't use anchor positioning. It is also a beta, 11 MB unpacked, and would overlap with reka-ui.Browser floor
From MDN browser-compat-data 8.1.9 (Chrome / Firefox / Safari):
<dialog>.showModal(),popover="manual",@starting-stylecommandfor)closedbypopover="hint"manual+ own Esc handlingChange map
OverlayModal/OverlayDrawer/OverlayConfirmDialog/AlertDialog+ Teleport<dialog>viauseNativeDialogOverlayTooltip,v-tooltipinActionIconButton/DisplayFilePath/DisplayDatebindTooltip/vTooltipvue-afloat.css, dialog keyframes inreka-ui.csstooltip.css(token@apply),dialog.css(transitions,::backdrop, scroll lock)vue-afloatz-modal-*,z-drawer-*,z-tooltipin the example configsBreaking changes
OverlayModal,OverlayDrawerandOverlayConfirmdrop thetoprop. They render in place.@antfu/design/styles/vue-afloat.cssis gone. Importstyles/tooltip.cssandstyles/dialog.cssinstead (styles.cssalready includes both).OverlayTooltip'splacementis now typed asTooltipPlacement(top,bottom-start, ...) instead ofstring.vue-afloatpeer dependency is removed.Visual changes
The look is meant to stay the same. Captured from Storybook on
mainand on this branch, in the same Chromium 158:main)v-tooltip, darkThe tooltip text is slightly smaller now, because it uses the token
text-sminstead of vue-afloat's inherited size.Boundaries and risks
v-tooltipappends to the root nodeportal.test.ts"native dialogs render in place",overlays.test.ts"stays inside an enclosing shadow root", ShadowRoot story checked in Chromiumv-model:openstays in synccommand="close"close without updating the modelcloseevent, which setsopen = falseoverlays.test.ts; Esc and backdrop checked in Chromiumclosedby="closerequest", no JS fallback wiredoverlays.test.ts; backdrop click checked in Chromium (stays open):root:has(...:modal) { overflow: hidden }; inside a shadow root (where:has()can't see): a counted JS lock inuseNativeDialogoverflow: hiddenwhile open in both the Modal and ShadowRoot stories;overlays.test.tscovers nested dialogs and unmount-while-openKnown gaps (not blocking):
aria-describedby. When the tooltip repeats anaria-label(e.g.ActionIconButtonwith the samelabelandtooltip), screen readers hear it twice.User prompts
Claude Code (Opus 5.5) in Paseo.
Verification
pnpm -F @antfu/design exec vitest run: 189 passed (newtest/overlays.test.ts, reworkedportal.test.tsandstyles.test.ts)pnpm run typecheck,pnpm run lint: cleanpnpm -F @antfu/design run docs:gen: idempotent over the committed docsstorybook build: succeededcommand,closedby,popover="hint"and anchor positioning)::modal; focus moves inside; Esc and backdrop close it; a click inside doesn't; scroll lock toggles.commandforwith no JS handler; Cancel gets focus; a backdrop click is ignored; Esc closes it.display: none.v-tooltippicks up thedarkscheme.visible->hidden->visibleacross open and Esc.closedbyfallbacks in a real browser (they're only covered in happy-dom).Written by Claude Code. The human set the direction (native features, no ui-sdk dependency, baseline + small JS) and hasn't reviewed the diff yet, so the reviewer is the first human to look.