Skip to content

[tooltip] Improve support for disabled button triggers#48622

Open
mayank99 wants to merge 6 commits into
mui:masterfrom
mayank99:mayank/tooltip-disabled-warning
Open

[tooltip] Improve support for disabled button triggers#48622
mayank99 wants to merge 6 commits into
mui:masterfrom
mayank99:mayank/tooltip-disabled-warning

Conversation

@mayank99

@mayank99 mayank99 commented Jun 4, 2026

Copy link
Copy Markdown

Main changes

This PR removes the warning that is triggered when Tooltip is used on a <button disabled> element. This warning is unnecessary in 2026 and encourages bad patterns. See #33182 (comment) for longer explanation.

Additionally, 5a10fee removes the disabled guard from #48606 and replaces it with better handling of disabled button triggers.

Documentation

The "Disabled elements" section of the Tooltip docs has been reworked to remove the wrapper <span> recommendation.

  • The default pointer-events: none needs to be undone from Buttons (see related section in Button docs). I believe this should be addressed within ButtonBase in a separate PR.
  • Keyboard accessibility (or lack thereof) is mentioned as a warning. This should be updated to recommend the focusableWhenDisabled prop (when available).

Signed-off-by: Mayank <9084735+mayank99@users.noreply.github.com>
@mayank99 mayank99 changed the title remove Tooltip warning about disabled buttons [Tooltip] remove warning about disabled buttons Jun 4, 2026
@code-infra-dashboard

code-infra-dashboard Bot commented Jun 4, 2026

Copy link
Copy Markdown

Deploy preview

Bundle size

Bundle Parsed size Gzip size
@mui/material 🔺+212B(+0.04%) 🔺+71B(+0.05%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes


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

Signed-off-by: Mayank <9084735+mayank99@users.noreply.github.com>
@zannager zannager added the scope: tooltip Changes related to the tooltip. label Jun 4, 2026
@zannager zannager requested a review from ZeeshanTamboli June 4, 2026 18:27
@mayank99 mayank99 changed the title [Tooltip] remove warning about disabled buttons [tooltip] remove warning about disabled buttons Jun 4, 2026

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

Thanks for the PR @mayank99

I added a commit with some runtime changes needed to handle some edge cases

Would you mind moving the changes from #48623 to this PR as well? I think it's better to have the docs updates directly here

Comment on lines -360 to -362
if (childNode?.disabled) {
return;
}

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.

This needed to be removed as well in addition to the warning

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you! I also found this when testing #48623 (comment)

Comment on lines +360 to +361
// However, if the trigger became disabled while the tooltip was already open,
// stray mouseover events must not cancel the pending close.

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.

I added the openedByDisabledTriggerRef in order to not affect the existing "tooltip trigger becomes disabled while tooltip is open" case

This comment was marked as resolved.

@mj12albert mj12albert changed the title [tooltip] remove warning about disabled buttons [tooltip] Improve support for disabled button triggers Jun 4, 2026
@mayank99

mayank99 commented Jun 4, 2026

Copy link
Copy Markdown
Author

Would you mind moving the changes from #48623 to this PR as well? I think it's better to have the docs updates directly here

Done in fe719f8. Originally I was trying to limit the scope, but it makes sense to update it together since this is now tackling disabled button triggers more broadly.

Comment on lines +444 to +450
await user.unhover(button);
await user.hover(screen.getByRole('tooltip'));
await act(async () => {
await new Promise((resolve) => {
setTimeout(resolve, 600);
});
});

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.

shouldn't the flow be: unhover button, wait for some time not enough for the tooltip to disappear, hover the tooltip, then check?

@mayank99 mayank99 Jun 8, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@mj12albert Since you wrote this test, would you be able to help with this?

Edit: Addressed in 1ef6079.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: tooltip Changes related to the tooltip.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants