feat(EbayTooltip): use floating-ui in infotip, tooltip, tourtip#566
Open
HenriqueLimas wants to merge 1 commit intomainfrom
Open
feat(EbayTooltip): use floating-ui in infotip, tooltip, tourtip#566HenriqueLimas wants to merge 1 commit intomainfrom
HenriqueLimas wants to merge 1 commit intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 57f07c2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates eBay UI Core React tooltips to use @floating-ui/react for consistent positioning/arrow behavior across Tooltip, Infotip, and Tourtip (Fixes #443).
Changes:
- Introduces shared
useFloatingTooltip(and movesuseFloatingDropdown) into a newcommon/floating-ui.tsmodule. - Wires Tooltip/Infotip/Tourtip overlays and arrows to floating-ui computed styles/refs and adds positioning options (offset/flip/shift/inline controls).
- Updates
TooltipContentto accept overlay/arrow refs and arrow styling.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ebayui-core-react/src/ebay-tourtip/ebay-tourtip.tsx | Uses useFloatingTooltip and passes overlay/arrow refs + styles into Tourtip content. |
| packages/ebayui-core-react/src/ebay-tooltip/ebay-tooltip.tsx | Wires Tooltip host/content to floating-ui refs and applies computed overlay/arrow styles. |
| packages/ebayui-core-react/src/ebay-infotip/ebay-infotip.tsx | Applies floating-ui positioning and arrow calculations to Infotip overlay. |
| packages/ebayui-core-react/src/common/tooltip-utils/tooltip-content.tsx | Adds overlay/arrow ref props and applies arrow inline styles from floating-ui. |
| packages/ebayui-core-react/src/common/floating-ui.ts | Adds shared floating-ui hooks for dropdowns and tooltips. |
| packages/ebayui-core-react/src/common/dropdown.ts | Re-exports dropdown floating hook/types from common/floating-ui. |
| .changeset/soft-turtles-heal.md | Declares a minor version bump for the new tooltip behavior/options. |
Comments suppressed due to low confidence (1)
packages/ebayui-core-react/src/common/tooltip-utils/tooltip-content.tsx:1
- This change removes the previous
POINTER_STYLES[pointer]merge, so any existingTooltipContentusages that don’t provide floating-uiarrowStyle(and any overlay spacing thatPOINTER_STYLEShandled) may regress. Consider preserving backward-compatible behavior by applying the old pointer-based styles whenarrowStyle/floating-ui refs aren’t provided (or migrating allTooltipContentconsumers in the same PR). Also,overlayRef/arrowReftypes are currently narrow (callback-only for overlay, RefObject-only for arrow); making themReact.Ref<HTMLElement>would be more flexible for consumers.
import React, { FC, CSSProperties, ReactNode, RefObject } from "react";
Comment on lines
+1
to
+2
| import { useRef } from "react"; | ||
| import { autoUpdate, flip, offset, shift, arrow, inline, useFloating, type Placement } from "@floating-ui/react"; |
Comment on lines
+61
to
+65
| export type FloatingTooltipHookArgs = { | ||
| open?: boolean; | ||
| hostRef?: React.RefObject<HTMLElement>; | ||
| options?: FloatingTooltipHookOptions; | ||
| }; |
Comment on lines
+77
to
+87
| export type FloatingTooltipHookReturn = { | ||
| overlayStyles: ReturnType<typeof useFloating>["floatingStyles"]; | ||
| arrowStyles: React.CSSProperties; | ||
| refs: { | ||
| host: ReturnType<typeof useFloating>["refs"]["reference"]; | ||
| overlay: ReturnType<typeof useFloating>["refs"]["floating"]; | ||
| arrow: React.RefObject<HTMLElement>; | ||
| setHost: ReturnType<typeof useFloating>["refs"]["setReference"]; | ||
| setOverlay: ReturnType<typeof useFloating>["refs"]["setFloating"]; | ||
| }; | ||
| }; |
Comment on lines
+89
to
+91
| export function useFloatingTooltip({ open, hostRef, options }: FloatingTooltipHookArgs): FloatingTooltipHookReturn { | ||
| const arrowRef = useRef<HTMLElement>(null); | ||
| const placement = options?.placement ?? POINTER_TO_PLACEMENT[options?.pointer ?? "bottom"]; |
Comment on lines
+106
to
+115
| } = useFloating({ | ||
| placement, | ||
| strategy: options?.strategy ?? "absolute", | ||
| open, | ||
| middleware, | ||
| whileElementsMounted: autoUpdate, | ||
| elements: { | ||
| reference: hostRef?.current, | ||
| }, | ||
| }); |
| refs, | ||
| middlewareData, | ||
| placement: finalPlacement, | ||
| } = useFloating({ |
| placement, | ||
| strategy: options?.strategy ?? "absolute", | ||
| open, | ||
| middleware, |
| import { excludeComponent, findComponent } from "../component-utils"; | ||
| import { PointerDirection, TooltipType } from "./types"; | ||
| import { DEFAULT_POINTER_DIRECTION, POINTER_STYLES, TYPE_ROLES } from "./constants"; | ||
| import { DEFAULT_POINTER_DIRECTION, TYPE_ROLES } from "./constants"; |
Comment on lines
+41
to
+42
| <span className={`${type}__overlay`} id={id} role={TYPE_ROLES[type] || null} style={style} ref={overlayRef}> | ||
| <span className={`${type}__pointer ${type}__pointer--${pointer}`} ref={arrowRef} style={arrowStyle} /> |
Comment on lines
+128
to
+136
| <TooltipContent | ||
| {...content.props} | ||
| type="tooltip" | ||
| style={{ ...overlayStyles, ...overlayStyle }} | ||
| pointer={pointer} | ||
| arrowStyle={arrowStyles} | ||
| overlayRef={refs.setOverlay} | ||
| arrowRef={refs.arrow} | ||
| /> |
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.
Description
Notes
The layouts are now matching marko layout where the arrow is close to the host
Screenshots
Checklist