Skip to content

[popups] Fix touch openMethod when tapping outside element bounds on Safari#3541

Merged
atomiks merged 3 commits into
mui:masterfrom
atomiks:fix/safari-hitslop-open-method
Dec 19, 2025
Merged

[popups] Fix touch openMethod when tapping outside element bounds on Safari#3541
atomiks merged 3 commits into
mui:masterfrom
atomiks:fix/safari-hitslop-open-method

Conversation

@atomiks

@atomiks atomiks commented Dec 14, 2025

Copy link
Copy Markdown
Contributor
  • For Dialog, Menu, Popover, Combobox, and Autocomplete, this fixes openType not being "touch" in initialFocus when tapping outside an element's bounds but inside the hitslop area
  • For Select, this fixes alignItemWithTrigger not being deactivated on touch when tapping outside the trigger's bounds but inside the hitslop area

@atomiks atomiks added type: bug It doesn't behave as expected. browser: Safari Affects or fixes behavior in Apple Safari. mobile Targets mobile platform. scope: all components Widespread work has an impact on almost all components. labels Dec 14, 2025
@pkg-pr-new

pkg-pr-new Bot commented Dec 14, 2025

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

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

commit: 46619c0

@mui-bot

mui-bot commented Dec 14, 2025

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+17B(0.00%) 🔺+9B(+0.01%)

Details of bundle changes


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

@netlify

netlify Bot commented Dec 14, 2025

Copy link
Copy Markdown

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 46619c0
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/694520be8912780008265f2b
😎 Deploy Preview https://deploy-preview-3541--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 force-pushed the fix/safari-hitslop-open-method branch from 159b585 to 41c246e Compare December 14, 2025 10:19
@atomiks atomiks marked this pull request as ready for review December 14, 2025 10:23

@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.

The solution seems quite "expensive" for such edge-cases.
Do you think it's worth adding the extra event listener to solve this?

Would this ever resolve to anything other than touch in the fallback case?
Could we sneak in a plain || 'touch' fallback? 🥷 🙈 😆

Comment thread packages/react/src/utils/useOpenInteractionType.ts
@atomiks

atomiks commented Dec 18, 2025

Copy link
Copy Markdown
Contributor Author

Would this ever resolve to anything other than touch in the fallback case?
Could we sneak in a plain || 'touch' fallback? 🥷 🙈 😆

It is indeed more expensive than I'd like. This seems like a decent solution, though the interaction type will never be "" in that case. Another solution is to use isIOS() but I am not sure if Android also has hitslop issues (Chrome touch DevTools doesn't seem to have it.)

@atomiks atomiks force-pushed the fix/safari-hitslop-open-method branch 3 times, most recently from 475e796 to 9da19f5 Compare December 18, 2025 21:24

@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.

Nice final solution. 👍
If we ever notice problems with this, a more robust solution could be explored.

I checked on Android, and at least on Chrome, it doesn't exhibit the same problem with empty openMethod when clicked in the "slop" area.

@LukasTy

LukasTy commented Dec 19, 2025

Copy link
Copy Markdown
Member

This seems like a decent solution, though the interaction type will never be "" in that case.

Should we limit the type value to account for this? 🤔
I don't think this is a BC. 🤷

@atomiks

atomiks commented Dec 19, 2025

Copy link
Copy Markdown
Contributor Author

Should we limit the type value to account for this? 🤔

Since it doesn't happen on Android, we can limit this to iOS

@atomiks atomiks force-pushed the fix/safari-hitslop-open-method branch from 120bbd0 to 46619c0 Compare December 19, 2025 09:54
@atomiks atomiks merged commit 3b05d1d into mui:master Dec 19, 2025
23 checks passed
@atomiks atomiks deleted the fix/safari-hitslop-open-method branch December 19, 2025 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

browser: Safari Affects or fixes behavior in Apple Safari. mobile Targets mobile platform. scope: all components Widespread work has an impact on almost all components. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants