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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onChange function doesn't return the selected child element #12448

Closed
2 tasks done
johuder33 opened this issue Aug 8, 2018 · 3 comments
Closed
2 tasks done

onChange function doesn't return the selected child element #12448

johuder33 opened this issue Aug 8, 2018 · 3 comments
Labels
component: select This is the name of the generic UI component, not the React module! discussion

Comments

@johuder33
Copy link

johuder33 commented Aug 8, 2018

When executiong onChange function for Select using a non native feature, it should return event and child but child element is not returning, I was debugging this by myself and I realize that onChange function that is executing belongs to a input element and not the onChange function that I passed downb to the props

I attached a screenshot to illustrate the bug

screen shot 2018-08-08 at 11 19 00

  • This is a v1.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Should return event and child element selected when executing onChange

Current Behavior

only return event when executing onChange

Steps to Reproduce

Just render the select component with non native, and try using a onChange function and get the child argument

Context

I want to get the child selected to get more information than value itself when selecting a option in Select component

Your Environment

Tech Version
Material-UI ^v1.2.1
React ^16.4.2
browser Google Chrome Version 68.0.3440.75 (Official Build) (64-bit) (Mac)
@oliviertassinari oliviertassinari added the component: select This is the name of the generic UI component, not the React module! label Aug 8, 2018
@oliviertassinari
Copy link
Member

oliviertassinari commented Aug 8, 2018

it should return event and child but child element is not returning

@johuder33 It's not what the documentation says:

The react element that was selected when native is false (default).

I want to get the child selected to get more information than value itself when selecting a option in Select component

Here is what you can use instead:

const child = event.target.options[event.target.options.selectedIndex];

@johuder33
Copy link
Author

@oliviertassinari sorry if I explain myself in wrong way, the docs says: function(event: object, child?: object) => void event: The event source of the callback. You can pull out the new value by accessing event.target.value.
child: The react element that was selected when native is false (default).

the dark words says that when native is false it should return the child argument, I am using the native: true, but not child element is returned

@oliviertassinari
Copy link
Member

the dark words says that when native is false it should return the child argument, I am using the native: true, but not child element is returned

@johuder33 Don't worry, things will be clearer after a good night sleep :).

Should we make both API by identically? I would say no, it's pretty specific. What's your use case? Why using the DOM to access the information, why don't you use the raw data?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: select This is the name of the generic UI component, not the React module! discussion
Projects
None yet
Development

No branches or pull requests

2 participants