Skip to content

[preview card] Support detached triggers - #3566

Merged
michaldudak merged 65 commits into
mui:masterfrom
michaldudak:preview-card-store
Jan 14, 2026
Merged

michaldudak merged 65 commits into
mui:masterfrom
michaldudak:preview-card-store

Conversation

@michaldudak

@michaldudak michaldudak commented Dec 17, 2025 •

Copy link
Copy Markdown
Member

Implemented detached / multiple trigger support in PreviewCard, similarly to #2336

It is now possible to define triggers outside of PreviewCard.Root using the handle prop. Multiple triggers per card with a dynamic payload are also implemented.

Playground: https://deploy-preview-3566--base-ui.netlify.app/experiments/preview-card/triggers
Docs: https://deploy-preview-3566--base-ui.netlify.app/react/components/preview-card#detached-triggers

@michaldudak michaldudak added type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. component: preview card Changes related to the preview card component. labels Dec 17, 2025
@mui-bot

mui-bot commented Dec 17, 2025 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+4.57KB(+1.10%) 🔺+770B(+0.58%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@pkg-pr-new

pkg-pr-new Bot commented Dec 17, 2025 •

Copy link
Copy Markdown
  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@3566
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@3566
    

commit: fe09485

@netlify

netlify Bot commented Dec 17, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit fe09485
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6967842a6301210008ef365d
😎 Deploy Preview https://deploy-preview-3566--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks atomiks mentioned this pull request Jan 13, 2026
1 task done
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jan 13, 2026
@michaldudak

Copy link
Copy Markdown
Member Author

@atomiks I addressed both your remarks.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is a drive-by change

Comment on lines +213 to +215
// If there's just one trigger, we can skip the auto-resize logic as
// the preview card will always be anchored to the same position.
const autoresizeEnabled = useStableCallback(() => store.context.triggerElements.size > 1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This isn't used in PopoverViewport/TooltipViewport

Comment on lines +107 to +110
// eslint-disable-next-line react-hooks/rules-of-hooks
const store = useRefWithInit(() => {
return externalStore ?? new PreviewCardStore<Payload>(initialState);
}).current;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Move externalStore out of useRefWithInit for hot reloading: 3575dfc

@LukasTy LukasTy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Awesome work. 👏 🎉
Looks great to me overall, just small nitpicks.

@atomiks

atomiks commented Jan 14, 2026 •

Copy link
Copy Markdown
Contributor

In "Controlled, detached triggers", when using a keyboard to focus links, if you press Esc and navigate to the next link, it doesn't open.

@michaldudak
michaldudak merged commit e8aa12f into mui:master Jan 14, 2026
@michaldudak
michaldudak deleted the preview-card-store branch January 14, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: preview card Changes related to the preview card component. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants