Skip to content

[popups] Refactor useDismiss to use an internal class instance - #3391

Closed
michaldudak wants to merge 12 commits into
mui:masterfrom
michaldudak:classy-interactions/useDismiss
Closed

michaldudak wants to merge 12 commits into
mui:masterfrom
michaldudak:classy-interactions/useDismiss

Conversation

@michaldudak

Copy link
Copy Markdown
Member

No description provided.

@michaldudak michaldudak added component: menu Changes related to the menu component. component: alert dialog Changes related to the alert dialog component. component: tooltip Changes related to the tooltip component. component: dialog Changes related to the dialog component. performance component: popover Changes related to the popover component. internal Behind-the-scenes enhancement. Formerly called “core”. labels Dec 2, 2025
@pkg-pr-new

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

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

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

commit: 1336154

@mui-bot

mui-bot commented Dec 2, 2025 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+4.21KB(+1.00%) 🔺+548B(+0.41%)

Details of bundle changes


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

@netlify

netlify Bot commented Dec 2, 2025 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit bc63c27
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69fdbb02ee797800083ab27a
😎 Deploy Preview https://deploy-preview-3391--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Dec 3, 2025

controller.useSetup();

React.useEffect(() => {

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.

Nitpick, but here you can save one function allocation:

Suggested change
React.useEffect(() => {
React.useEffect(controller.disposeEffect);

Where disposeEffect is:

  public disposeEffect() {
    return () => {
      this.cancelDismissOnEndTimeout.clear();
      this.clearInsideReactTreeTimeout.clear();
    }
  }

@romgrk romgrk Dec 4, 2025 •

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.

disposeEffect = ... for the bound this though. The useTimeout hook is a good model for class-based hooks (and it saves another allocation by using useOnMount instead of useEffect(..., [])). I've been thinking we might want to create a base class for class hooks to standardize and/or manage automatic resource cleanup.

@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jan 20, 2026
@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Feb 12, 2026
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label May 8, 2026
@michaldudak

Copy link
Copy Markdown
Member Author

After #4661, there's no more noticeable improvement in the mount time of this PR.

@michaldudak michaldudak closed this May 8, 2026
@michaldudak
michaldudak deleted the classy-interactions/useDismiss branch August 12, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: alert dialog Changes related to the alert dialog component. component: dialog Changes related to the dialog component. component: menu Changes related to the menu component. component: popover Changes related to the popover component. component: tooltip Changes related to the tooltip component. internal Behind-the-scenes enhancement. Formerly called “core”. performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants