Skip to content

[utils] Fix event handling in useEnhancedClickHandler - #3981

Merged
atomiks merged 2 commits into
mui:masterfrom
sai6855:useenhanceclick
Feb 5, 2026
Merged

atomiks merged 2 commits into
mui:masterfrom
sai6855:useenhanceclick

Conversation

@sai6855

@sai6855 sai6855 commented Feb 5, 2026 •

Copy link
Copy Markdown
Member

Fix event handling in useEnhancedClickHandler to support pointerType

@sai6855 sai6855 added type: bug It doesn't behave as expected. package: utils Specific to the utils package. labels Feb 5, 2026
@pkg-pr-new

pkg-pr-new Bot commented Feb 5, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

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

commit: d92783b

@mui-bot

mui-bot commented Feb 5, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react ▼-1B(0.00%) 0B(0.00%)

Details of bundle changes


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

@netlify

netlify Bot commented Feb 5, 2026

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 0a5c918
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/698477481338d60008b84f3d
😎 Deploy Preview https://deploy-preview-3981--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.

if ('pointerType' in event) {
// Chrome and Edge correctly use PointerEvent
handler(event, event.pointerType);
} else {

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.

Added this else block after line 39 to prevent the handler from being
called twice per click.

@netlify

netlify Bot commented Feb 5, 2026

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit d92783b
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6984776f9fb24200082cd947
😎 Deploy Preview https://deploy-preview-3981--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.

@sai6855
sai6855 marked this pull request as ready for review February 5, 2026 11:02
Copilot AI review requested due to automatic review settings February 5, 2026 11:02
@greptile-apps

greptile-apps Bot commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

Fixed a bug in useEnhancedClickHandler where the handler was being invoked twice in Chrome and Edge browsers when a PointerEvent was available.

  • Added else clause to prevent double handler invocation when pointerType exists in the event
  • Before: handler was called unconditionally after the if block, causing duplicate calls
  • After: handler is only called once per click event, using either event.pointerType or the fallback lastClickInteractionTypeRef.current

Confidence Score: 5/5

  • This PR is safe to merge with no concerns
  • The change is a clear bug fix that prevents double handler invocation. The logic is correct and straightforward - adding an else clause ensures the handler is called exactly once per click event, regardless of browser type
  • No files require special attention

Important Files Changed

Filename Overview
packages/utils/src/useEnhancedClickHandler.ts Fixed double handler invocation bug by adding else clause to prevent calling handler twice when pointerType exists

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in the useEnhancedClickHandler function where the handler was being called twice when the event contained a pointerType property. The issue was that the fallback handler call was not wrapped in an else block, causing it to execute unconditionally after the conditional call.

Changes:

  • Fixed the event handling logic by adding an else block to ensure only one handler call occurs per click event

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@atomiks atomiks changed the title [click-handler] Fix event handling in useEnhancedClickHandler to support pointerType [utils] Fix event handling in useEnhancedClickHandler Feb 5, 2026
@atomiks
atomiks merged commit ffa61d6 into mui:master Feb 5, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: utils Specific to the utils package. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants