Material UI SelectField onChange not working
See original GitHub issueHi, I have implemented mobx-react-form successfully in my project but now I’m trying to get a SelectField working.
This is what I have.
// MaterialSelectFieldComponent.js
import React from 'react';
import {observer} from 'mobx-react';
import SelectField from 'material-ui/SelectField';
import MenuItem from 'material-ui/MenuItem';
export default observer(({field}) => (
<div>
<SelectField {...field.bind()} >
{field.options.map(({value,label}) => {
return (<MenuItem key={value} value={value} primaryText={label} />)
})}
</SelectField>
</div>
));
// bindings
MaterialSelectField: {
id: 'id',
name: 'name',
value: 'value',
label: 'floatingLabelText',
disabled: 'disabled',
error: 'errorText',
onChange: 'onChange',
}
// fields
a_dummy_field: {
label: 'Nice Field',
rules: 'required',
bindings: 'MaterialSelectField',
options: [{value:1, label: 'Yes'}]
}
and <MaterialSelectField field={form.$('a_dummy_field')} />
With this the form, the field and its options are rendered, but selecting one option does not set the value in the select field. Am I missing something? Thanks in advance.
Issue Analytics
- State:
- Created 7 years ago
- Comments:39 (22 by maintainers)
Top Results From Across the Web
Material ui select onchange is not bubbling - Stack Overflow
The event that triggers the change does bubble, but it is not a "change" event. The onChange function that you provide gets called...
Read more >on change for Material UI Select component not triggered #322
What you did: I am trying to fire the onChange method of the Material UI Select. ... fireEvent.change not working on input elements...
Read more >React Select component - Material UI - MUI
It's enabled with the multiple prop. Like with the single selection, you can pull out the new value by accessing event.target.value in the...
Read more >firing change event for material-ui select - CodeSandbox
firing change event for material-ui select. 1. Embed Fork Create Sandbox Sign in. Sandbox Info. firing change event for material-ui select.
Read more >How to use Material UI Select in React - Refine Dev
We'll discover the Material UI (MUI) select component with examples. ... It does not, however, inherit the Select variant value.
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
React Native does not have an event object passed to the
onChange
, as you can see in the official doc, you need to useonChangeText
, this should work without bindings:I’m so sorry @foxhound87 I tried again, just updated the package version to
1.20.0
and now this is workingwhere payload is the actual value returned from SelectField. I was my mistake.
Thank you so much