Repository navigation
feat: [toast, popover] add anchored toasts and popover arrow - #950
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedYou'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. View limit details
No actionable comments were generated in the recent review.
|
commit: |
fe3b858 to
7261fdc
Compare
- 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.
Summary
Add anchored toasts.
toastManager.add({ title: 'Copied', positionerProps: { anchor: el } })shows the toast next toelwith an arrow. Toasts without an anchor stay in the corner stack as before.Add
showArrowtoPopover.Content(off by default). The arrow uses Tooltip's arrow styles, which move toshared/arrowso Tooltip, Popover, and Toast share one copy.Add data-slots
toast-anchored-viewport,toast-positioner,toast-arrow, andpopover-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.Providerrenders a second provider for it.addroutes bypositionerProps.anchor, andcloseandupdatego to both. This keeps onetoastManagerand oneuseToastManager(), and uses Base UI's ownpositionerPropsoption. The hook'stoastslist holds stacked toasts only. Popover's Base UI port only ported the panel it had, which never had an arrow.Breaking: no.
toastManager,useToastManager(), andcreateToastManager()keep their signatures and behavior for toasts without an anchor.I have followed the pull request section of the contributing guide.