Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tooltip on ToggleButton in ToggleButtonGroup #36270

Closed
2 tasks done
AngyDev opened this issue Feb 20, 2023 · 3 comments 路 Fixed by #40220
Closed
2 tasks done

Tooltip on ToggleButton in ToggleButtonGroup #36270

AngyDev opened this issue Feb 20, 2023 · 3 comments 路 Fixed by #40220
Assignees
Labels
accessibility a11y component: toggle button This is the name of the generic UI component, not the React module! component: tooltip This is the name of the generic UI component, not the React module! customization: css Design CSS customizability enhancement This is not a bug, nor a new feature package: base-ui Specific to @mui/base package: material-ui Specific to @mui/material

Comments

@AngyDev
Copy link

AngyDev commented Feb 20, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 馃暪

Link to live example: https://codesandbox.io/s/upbeat-sinoussi-bgbdsj?file=/src/App.js

Steps:

  1. Wrap the ToggleButton inside a Tooltip
  2. Run the code
  3. See the console for warning

In the last button I added the span, as the documentation said, but the button has a different style

Current behavior 馃槸

I have a ToggleButtonGroup with a list of ToggleButton, I wanted to add Tooltips on the buttons, I followed the documentation and everything was fine. But I have some conditional buttons that can be disabled for some reason. When the buttons are disabled I get the following error:

MUI: You are providing a disabled `button` child to the Tooltip component.
A disabled element does not fire events.
Tooltip needs to listen to the child element's events to display the title.

Add a simple wrapper element, such as a `span`. 

I added the span tags but there is another problem: the styles have changed and the buttons cannot be clicked.
I followed other issues related to this problem but no workaround worked for me.
Do you have any suggestions?

Expected behavior 馃

It should be possible to add a tooltip to ToggleButton and disable it if the button is disabled without errors and without adding extra tags

Context 馃敠

Since ToggleButtons are IconButton (at least that's how we intend to use it) it would be helpful to a user to see what that button will do and the best way for that is Tooltip

Your environment 馃寧

Tech Version
Material-UI v5.11.9
React v18.2
Browser any
@AngyDev AngyDev added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Feb 20, 2023
@zannager zannager added the component: tooltip This is the name of the generic UI component, not the React module! label Feb 20, 2023
@siriwatknp
Copy link
Member

There are 2 problems with this issue:

  1. The disabled toggle button + tooltip is not supported. Similar to Tooltip doesn't work for <IconButton disabled>聽#8416, the proposed fix is [Button] Implement inclusive disabled state聽#27719.
  2. The ToggleButtonGroup is using React.cloneElement, to pass props to ToggleButton. The implementation should change to React context.

@siriwatknp siriwatknp added component: toggle button This is the name of the generic UI component, not the React module! customization: css Design CSS customizability accessibility a11y enhancement This is not a bug, nor a new feature package: base-ui Specific to @mui/base package: material-ui Specific to @mui/material and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Feb 27, 2023
@bmakan
Copy link

bmakan commented Aug 25, 2023

Another issue related to Tooltip and ToggleButton:
I wrapped my ToggleButtons with Tooltips and they are not highlighted when selected.

@wfsm
Copy link

wfsm commented Oct 20, 2023

any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility a11y component: toggle button This is the name of the generic UI component, not the React module! component: tooltip This is the name of the generic UI component, not the React module! customization: css Design CSS customizability enhancement This is not a bug, nor a new feature package: base-ui Specific to @mui/base package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants