Skip to content

feat: [toast, popover] add anchored toasts and popover arrow - #950

Merged
rohanchkrabrty merged 6 commits into
mainfrom
feat/anchored-toast-popover-arrow
Oct 27, 2026
Merged

rohanchkrabrty merged 6 commits into
mainfrom
feat/anchored-toast-popover-arrow

Conversation

@ravisuhag

Copy link
Copy Markdown
Member

Summary

  • Add anchored toasts. toastManager.add({ title: 'Copied', positionerProps: { anchor: el } }) shows the toast next to el with an arrow. Toasts without an anchor stay in the corner stack as before.

  • Add showArrow to Popover.Content (off by default). The arrow uses Tooltip's arrow styles, which move to shared/arrow so Tooltip, Popover, and Toast share one copy.

  • Add data-slots toast-anchored-viewport, toast-positioner, toast-arrow, and popover-arrow, with tests and docs.

  • Why it's like this: Toast moved to Base UI in Mar 2026 (feat: migrate Toast to Base UI #671) and only the corner toasts were ported. Base UI needs anchored toasts in a separate provider. Each Apsara manager now holds a second, internal Base UI manager, and Toast.Provider renders a second provider for it. add routes by positionerProps.anchor, and close and update go to both. This keeps one toastManager and one useToastManager(), and uses Base UI's own positionerProps option. The hook's toasts list holds stacked toasts only. Popover's Base UI port only ported the panel it had, which never had an arrow.

  • Breaking: no. toastManager, useToastManager(), and createToastManager() keep their signatures and behavior for toasts without an anchor.

  • I have followed the pull request section of the contributing guide.

@vercel

vercel Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
apsara Ready Ready Preview Oct 27, 2026 7:02pm UTC

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 16 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5d62b7cc-dcfc-4494-a128-8748e053b126
Commits

Reviewing files that changed from the base of the PR and between 0875da4 and c7c45ae.

Files selected for processing: 7
  • packages/react/components/popover/popover.tsx
  • packages/react/components/preview-card/__tests__/preview-card.test.tsx
  • packages/react/components/preview-card/preview-card.module.css
  • packages/react/components/preview-card/preview-card.tsx
  • packages/react/components/toast/toast-root.tsx
  • packages/react/components/tooltip/tooltip-content.tsx
  • packages/react/shared/arrow/arrow.tsx

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2f40c555-9936-4e24-a981-c19757c3a434
Commits

Reviewing files that changed from the base of the PR and between 898d17e and 0875da4.

Files selected for processing: 11
  • apps/www/src/content/docs/components/popover/index.mdx
  • apps/www/src/content/docs/components/toast/demo.ts
  • apps/www/src/content/docs/components/toast/index.mdx
  • apps/www/src/content/docs/components/toast/props.ts
  • packages/react/components/popover/__tests__/data-slots.test.tsx
  • packages/react/components/toast/__tests__/data-slots.test.tsx
  • packages/react/components/toast/__tests__/toast.test.tsx
  • packages/react/components/toast/toast-manager.ts
  • packages/react/components/toast/toast-provider.tsx
  • packages/react/components/toast/toast-root.tsx
  • packages/react/components/toast/toast.module.css
Files skipped from review as they are similar to previous changes: 1
  • apps/www/src/content/docs/components/toast/demo.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

PopoverContent now supports an optional arrow, with a conditional default side offset. Toast managers route anchored toasts to a separate store and viewport while retaining shared manager operations. Tooltip, Popover, and anchored toasts use shared arrow rendering and styles. Documentation, demos, and tests cover the new behavior.

Sequence Diagram(s)

sequenceDiagram
  participant Application
  participant useToastManager
  participant toastManager
  participant anchoredStore
  participant ToastProvider
  participant AnchoredToasts
  participant AnchoredToastRoot
  Application->>useToastManager: add with positionerProps.anchor
  useToastManager->>toastManager: pass add options
  toastManager->>anchoredStore: add anchored toast
  ToastProvider->>AnchoredToasts: render anchored notifications
  AnchoredToasts->>AnchoredToastRoot: render toast
  AnchoredToastRoot->>Positioner: place toast relative to anchor
Loading

Priority: Normal

Merge Risk: Minimal · previous review 0875d

The anchored-toast and Popover-arrow changes have no identified issue requiring correction before merge. Normal checks still apply.

Pre-merge checks: Passed 5
Check name Status Explanation
Description check Passed The description directly covers the anchored toast and popover arrow changes, including implementation details, compatibility, tests, and documentation.
Title check Passed The title clearly and concisely identifies the two main changes: anchored toasts and a popover arrow.
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/@raystack/apsara@950

commit: c7c45ae

- Build the manager and hook methods with one wrap function. The hook
  finds the anchored manager through the stacked store, so
  ToastManagerContext is removed.
- Render the anchored provider first, so hook adds in mount effects
  reach it.
- Drop positionerProps from stacked toasts, so anchor: null keeps swipe.
- Label the anchored viewport "Anchored notifications", so there is one
  "Notifications" region.
- Hide anchored toasts over the limit or with a hidden anchor, and show
  newer ones on top.
- Document the routing rules and fix the Popover sideOffset playground
  default.
- Keep the anchored Base UI manager on the toast manager under a symbol
  key, and put the manager in ToastManagerContext.
- useToastManager reads the context instead of a WeakMap link that
  Toast.Provider wrote during render.
- StackedToasts no longer has to render before children.
- Render an anchored toast with the tooltip surface and only its title.
  Add a showArrow option for the arrow, with sideOffset 4, or 10 with
  the arrow.
- Merge positionerProps in update and in promise results, so a partial
  placement change keeps the anchor. Drop positionerProps from stacked
  toast updates.
- Keep the methods from useToastManager the same when the toast list
  changes, so an effect that depends on add runs once.
- shared/arrow exports an Arrow component instead of a class name and
  an SVG. Each Base UI Arrow part renders it through the render prop.
- Tooltip, Popover, anchored Toast, and PreviewCard use it.
- PreviewCard drops its copy of the arrow CSS and SVG.
@rohanchkrabrty
rohanchkrabrty merged commit bb61080 into main Oct 27, 2026
8 checks passed
@rohanchkrabrty
rohanchkrabrty deleted the feat/anchored-toast-popover-arrow branch October 27, 2026 19:03

This branch was successfully deployed

1 active deployment
Preview — c7c45ae3 Deployed Oct 27, 2026 by vercel[bot]
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.

2 participants