MenuItem wrapped in Tooltip breaks Select's onChange callback
See original GitHub issueIf you want to explain a Select field’s MenuItems via a tooltip, the onChange will no longer work.
- [ x] I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
Select a new value, state is updated
Current Behavior
Crash. Event target is the tooltip, not the MenuItem, and thus there is no target value
Steps to Reproduce (for bugs)
<FormControl>
<InputLabel htmlFor='activity-level'>Activity Level</InputLabel>
<SelectField
input={<Input name="sort" id='activity-level' />}
onChange={this.handleFormChange('activityLevel')}
value={this.state.activityLevel}
>
<Tooltip id="tooltip-sedentary" title="Little or no exercise" placement="right">
<MenuItem value={'sedentary'} >Sedentary</MenuItem>
</Tooltip>
<Tooltip id="tooltip-light" title="1-3/week" placement="right">
<MenuItem value={'light'} >Light</MenuItem>
</Tooltip>
</SelectField>
</FormControl>
handleFormChange(key) {
return (event) => {
debugger
let newState = {};
newState[key] = event.target.value;
this.setState(newState);
}
}
Your Environment
Tech | Version |
---|---|
Material-UI | 1.0.0-beta.26 |
React | 16.1.0 |
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
MenuItem wrapped in Tooltip breaks Select's onChange ...
MenuItem wrapped in Tooltip breaks Select's onChange callback #9737 · Comments · Expected Behavior · Current Behavior · Steps to Reproduce (for bugs)....
Read more >Material-UI - Tooltip on Select/MenuItem component stays ...
I want it to disappear as soon as the Select is clicked so that it doesn't stay over the MenuItems (Changing the zIndex...
Read more >show message validate error input once at a time ant design ...
Now, just taking a look at your code snippet, I suggest you take a different approach. Instead of wrapping all three of your...
Read more >1. The ZK User Interface Markup Language - Courses
An input control notifies the application with the onChange event if its content is changed by the user. Notice that, when the onChange's...
Read more >React menu component - szhsin/react-menu
FocusableItem is a special menu item. It's used to wrap elements which are able to receive focus, such as input or button. It...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@JarLowrey You need to create a custom menu item component, forward the injected property to the
MenuItem
. It’s fundamentally the same as what it’s documented here https://material-ui-next.com/guides/composition/#wrapping-components.@Jakeron thanks for providing this closure. I ended up just putting the tooltip inside the menuselect, rather than the reverse to solve my problem