feat(usePopover): add a pluggable positioning-adapter seam - #846
Merged
johnleider merged 8 commits intoAug 20, 2026
Conversation
usePopover had exactly one positioning implementation - CSS anchor
positioning, hard-coded - and no way to supply another. CSS anchor
positioning is unavailable in Firefox ESR and pre-26 Safari; when
unsupported, the emitted CSS properties are silently ignored and
content renders unanchored at position: fixed. There was also no
JS-positioning-library escape hatch, bundled or otherwise.
Adds a PopoverAdapter abstract class (adapters/adapter.ts) following
the same pattern as LoggerAdapter/LocaleAdapter/StorageAdapter.
V0PopoverAdapter (the default) reproduces today's CSS anchor
positioning output byte-for-byte - verified by the existing
usePopover test suite passing unchanged. v0 ships no JS-engine
adapter of its own; the deliverable is the contract.
usePopover's adapter.setup() context carries the previously-missing
activator element via a new attachAnchor() (companion to attach()),
plus a normalized { side, align } placement descriptor derived from
positionArea (derivePlacement, in adapters/placement.ts), with the
raw CSS value always available as an escape hatch.
Popover.Root, Tooltip.Root, Select.Root, and createCombobox all
thread an adapter option through to their usePopover() call
(positionAdapter on createCombobox, since it already has its own
adapter option for query filtering).
johnleider
reviewed
Aug 13, 2026
johnleider
left a comment
Member
There was a problem hiding this comment.
Architecture skim: the adapter seam is right (PopoverAdapter + V0PopoverAdapter CSS default, no floating-ui, attachAnchor, positionAdapter on combobox). One descriptor bug before merge — inline on placement.ts.
…ottom derivePlacement() was mapping logical inline-start/inline-end onto the block axis (top/bottom) alongside block-start/block-end. inline-start/ inline-end are the inline axis (left/right in LTR) - conflating the two axes hands a JS positioning adapter the wrong side. V0PopoverAdapter is unaffected either way since it renders `raw` verbatim, never the normalized side/align. Replaces the if/else-if chain with a keyword lookup table per lint (unicorn/prefer-switch) and updates the block-start/inline-start test case to assert the correct axis.
Contributor
Author
|
Good catch, fixed in b410039 — |
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.
Addresses #733
Scope of this PR
This covers the checklist items that live in
packages/0:usePopover/adapters/adapter.tsV0PopoverAdapterreproducing current CSS anchor output byte-for-byteattachAnchor()adapteroption throughPopoverRoot,TooltipRoot,SelectRoot,createComboboxusePopovertest suite passes unmodified against the new code path)Non-goals from the issue are respected: no
floating-uidependency anywhere inpackages/0, no bundled JS adapter, CSS anchor positioning stays the zero-cost default.Naming
Went with
PopoverAdapterper the convention the issue itself cites (.claude/rules/implementation.md's "composition noun matches the composable name verbatim"), over the more precisePositionAdapterthe issue also raised as worth settling in review. Easy to rename before merge if you'd rather havePositionAdapter— it's a single identifier used consistently, no structural difference either way.Design notes
Context shape.
PopoverAdapterContextcarriesanchorName(the CSS custom-ident),anchorEl/contentEl(both element refs — the concrete blocker the issue called out, sinceusePopoverpreviously only ever saw the content element),isOpen,placement, andpositionTry.setup(context)returns the reactive style object for the content element — forV0PopoverAdapterthat's the existing six CSS declarations; for a JS engine it'd be computedtop/left/position.Placement descriptor.
derivePlacement()(adapters/placement.ts) does a best-effort parse of thepositionAreaCSS value into{ side, align }— covers the common cases ('bottom','top span-left', logicalblock-start/block-end) and falls back tobottom/centerfor anything it doesn't recognize, withrawalways carrying the original value verbatim. I didn't try to build a complete grammar for everyposition-areacompound value — the issue asked for a "raw passthrough escape hatch so the CSS path loses no expressiveness," whichrawprovides regardless of what the normalized descriptor captures.createCombobox's option ispositionAdapter, notadapter— it already has anadapter?: ComboboxAdapteroption for query filtering, so reusing the name would be ambiguous.Popover.Root/Tooltip.Root/Select.Rootdon't have that collision and use plainadapter.Lifecycle.
adapter.dispose?.()runs ononScopeDispose, with Vue 3.5'sfailSilentlyflag —usePopover()is routinely called outside an active effect scope (directly in tests, for instance), which would otherwise emit a spurious warning.Test plan
usePopovertest suite (17 tests) passes unchanged against the new adapter-basedcontentStyles— this is the "default output identical to today" proof, since those tests assert exact CSS outputderivePlacement(),V0PopoverAdapter, and theusePopoveradapter seam (custom adapter receiving the right context,attachAnchor/attachpopulatinganchorEl/contentEl, dispose lifecycle) — 100% line/branch coverage on all new filesPopover/index.browser.test.tsmounting the fullRoot+Activator+Contentstack with a custom adapter, proving both DOM elements reach it and its styles are applied to (not merged with) the content elementpnpm vitest run --project v0:unit --project v0:browser→ 6561 passed, 3 skipped (full suite, no regressions)pnpm --filter=@vuetify/v0 typecheckcleanpnpm eslintclean on all changed filespnpm vitest run packages/0/src/surface.test.ts— updated the frozen public-surface list for the 3 new exports (PopoverAdapter,V0PopoverAdapter,derivePlacement)@vuetify/v0)One environment caveat: I couldn't get a fully clean local
pnpm run build:docs— this checkout has pre-existing case-collision issues on macOS's case-insensitive filesystem between intentionally-paired files likeEqualizer.vue/equalizer.vue(unrelated to this PR, reproducible on a pristinedevcheckout with zero changes). I reviewed theuse-popover.mddiff manually for syntax correctness against the page's existing conventions; CI'sdocs-checkruns on a case-sensitive runner and will give the real signal.