[Tooltip] Support tooltips for disabled buttons #22937
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
https://deploy-preview-22937--material-ui.netlify.app/components/tooltips/#disabled-elements
Use pointer events instead of mouse events. That way we don't have to deal with quirky mouseenter on disabled buttons (which should work by spec but is not implemented for historic reasons: w3c/pointerevents#177). We can leverage pointer events even though we support Safari 12.1 on iOS because in that environment the tooltip is triggered by the touchstart event.
Needs:
From that issue it sounds like mouseenter not firing is due to a historical misinterpretation of the spec.
Since PointerEvents are new browsers had a chance to remedy this without breaking compat.
Right now we implement most of the expected behavior for disabled elements by adding
pointer-events: none;
.We do this for the anchor and
div[role="button"]
use case as well as to not apply hover styles.I would propose that we rather implement these behaviors properly so that we have better support for the default
<button type="button" />
use case e.g. allowcursor: not-allowed
Motivation
Wrapper elements for disabled buttons with tooltips are pretty hard since we only want event handlers on the wrapper. Everything else should go on the button e.g.
aria-label
.