Skip to content

feat(EbayTooltip): use floating-ui in infotip, tooltip, tourtip#566

Open
HenriqueLimas wants to merge 1 commit intomainfrom
feat/react-tooltip-flating-ui
Open

feat(EbayTooltip): use floating-ui in infotip, tooltip, tourtip#566
HenriqueLimas wants to merge 1 commit intomainfrom
feat/react-tooltip-flating-ui

Conversation

@HenriqueLimas
Copy link
Member

Description

  • Use floating-ui in all react tooltips

Notes

The layouts are now matching marko layout where the arrow is close to the host

Screenshots

Screenshot 2026-03-13 at 5 30 18 PM Screenshot 2026-03-13 at 5 31 45 PM

Checklist

  • I verify all changes are within scope of the linked issue
  • I added/updated/removed testing (Storybook in Skin) coverage as appropriate
  • I tested the UI in all supported browsers
  • I tested the UI in dark mode and RTL mode

@HenriqueLimas HenriqueLimas self-assigned this Mar 14, 2026
Copilot AI review requested due to automatic review settings March 14, 2026 00:32
@changeset-bot
Copy link

changeset-bot bot commented Mar 14, 2026

🦋 Changeset detected

Latest commit: 57f07c2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@ebay/ui-core-react Minor

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 moves useFloatingDropdown) into a new common/floating-ui.ts module.
  • Wires Tooltip/Infotip/Tourtip overlays and arrows to floating-ui computed styles/refs and adds positioning options (offset/flip/shift/inline controls).
  • Updates TooltipContent to 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 existing TooltipContent usages that don’t provide floating-ui arrowStyle (and any overlay spacing that POINTER_STYLES handled) may regress. Consider preserving backward-compatible behavior by applying the old pointer-based styles when arrowStyle/floating-ui refs aren’t provided (or migrating all TooltipContent consumers in the same PR). Also, overlayRef/arrowRef types are currently narrow (callback-only for overlay, RefObject-only for arrow); making them React.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}
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ebay-tourtip: Should automatically update position for smaller screens

2 participants