Add @offset and @shift to Popover (CSS anchor positioning)#685
Add @offset and @shift to Popover (CSS anchor positioning)#685
Conversation
|
|
Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
…S anchor positioning Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
| @copilot there are lint failures |
Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
| * This argument is forwarded to the `<FloatingUI>` component. | ||
| * Uses CSS anchor positioning (`position-area`) under the hood. | ||
| */ | ||
| shiftOptions?: HookSignature["Args"]["Named"]["shiftOptions"]; |
There was a problem hiding this comment.
@copilot is there no way to manage shift / offset options with the native thing?
There was a problem hiding this comment.
Offset: yes — setting margin on the positioned element creates a gap between anchor and content, so we could expose an @offset arg that sets margin in the applyAnchorPositioning modifier.
Shift: no direct equivalent. CSS anchor positioning's position-try-fallbacks (what we already set) provides flip behavior (tries the opposite side when overflowing), but there's no native CSS mechanism for "slide along the current side to stay in the viewport" — that requires JS. Custom @position-try at-rules could define explicit inset overrides but they'd be static, not viewport-aware.
Happy to add @offset support if that's desirable.
| Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
Restores
@offsetand@shiftarguments dropped when floating-ui was replaced with CSS anchor positioning.@offset?: numberGap in pixels between the anchor and the floating element. Applied as CSS
marginon the inward-facing side (margin-topforbottomplacement, etc.).@shift?: boolean | number | { padding?: number }Slides the floating element along its placement axis to keep it within the viewport. CSS Anchor Positioning has no native shift equivalent — this is implemented via a single
requestAnimationFramethat reads the bounding rect post-layout and applies a margin correction.true— shift with 0px viewport paddingnumber— shift with that many pixels from the viewport edge{ padding: number }— same as the number formCleanup cancels any pending rAF and removes all applied margin properties.
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.