-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Tooltip] Use media queries for applying "mobile styles" #23453
Conversation
The original incentive for not using |
So |
What part of the PR description is unclear to you? |
From my perspective:
So there are no issues (safe)? |
So the current approach is already not correct in your opinion. That's a good starting point. Since neither the current nor the media query approach are perfect we should go with the CSS solution since that has less overhead.
No, it's unclear. Since reading from a ref during render is generally unsafe and we have an alternate, concurrent safe, CSS approach we should use that instead of trying to figure out if an unsafe pattern is safe. If we use JS we need a rationale for it and I haven't seen one. |
The rationale I see is that: CSS has no primitives that allow us to know if action comes from a mouse or a touch. We can work around it with JS. It seems that we have to find the least worse option. The drawbacks of each option:
|
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/mui-org/material-ui/gqwbxgzy7 |
This is definitely incorrect implementation and doesn't even implement the expected behavior in all cases. But considering that it seems like it's more important to use the original implementation, I'm not going to argue further. It's impossible to argue against "the initial implementation is correct" sentiment. |
I think that it's a dilemma, I have seen 3 options #23453 (comment) with each its own drawback. For the next step, we could wait for a developer to open an issue, and discuss it further at this point? For instance, maybe we could move from reading a ref in the render to reading a React state. |
Replaces
.touch
class with@media (pointer: coarse) .MuiTooltip-tooltip
.Instead of applying the mobile styles depending on the input modality we apply them by the pointer granularity. That way we use less JS and are sure we don't have any CM problems (reading from a ref during render should be safe here but not trivial to determine).
caniuse data