Skip to content

Feat/floating UI positioning - #2161

Open
Parvinmh wants to merge 17 commits into
usablica:masterfrom
Parvinmh:feat/floating-ui-positioning
Open

Feat/floating UI positioning#2161
Parvinmh wants to merge 17 commits into
usablica:masterfrom
Parvinmh:feat/floating-ui-positioning

Conversation

@Parvinmh

Copy link
Copy Markdown
Contributor
  • Replaced the scattered, hand-rolled positioning logic with a self-contained middleware engine inspired by @floating-ui/dom
  • offset, flip, and shift are now composable middleware factories — same mental model as floating-ui
  • Tooltip and hint positioning now use computePosition() instead of custom checkLeft/checkRight/alignTooltip functions
  • Arrow position is corrected automatically when shift nudges the tooltip

What changed

New: src/packages/positioning/index.ts
A standalone positioning engine with a middleware pipeline:

  • offset(value) — gaps the floating element from the reference along main/cross axes
  • flip(options) — switches to the best available placement when the primary one overflows; uses a reset mechanism so offset re-applies on the new placement
  • shift(options) — nudges the floating element to stay within the viewport when flip alone isn't enough
  • computePosition() — runs the pipeline, returns CSS-ready x/y plus viewport-relative coords for overflow checks
  • autoUpdate() — re-runs position on scroll, resize, and ResizeObserver

Changed: tooltip.ts and hint/position.ts
Both now delegate entirely to computePosition(). The old manual geometry (checkLeft, checkRight, alignTooltip, alignHintPosition switch/case) is gone.

New: tooltipArrow.ts
Extracted from tooltip.ts. computeArrowStyles() corrects the arrow's CSS position when shift has moved the tooltip, so the arrow keeps pointing at the reference element.

Removed: tooltipPosition.ts + its tests
determineAutoPosition and determineAutoAlignment were fully replaced by the flip middleware and are no longer needed.

@vercel

vercel Bot commented Apr 27, 2026

Copy link
Copy Markdown

@Parvinmh is attempting to deploy a commit to the Pean Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Apr 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
intro-js Ready Ready Preview, Comment May 11, 2026 7:59am

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant