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

[Select] onBlur event target #12204

Closed
Mangatt opened this issue Jul 20, 2018 · 7 comments
Closed

[Select] onBlur event target #12204

Mangatt opened this issue Jul 20, 2018 · 7 comments
Labels
component: select This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process. new feature New feature or request

Comments

@Mangatt
Copy link
Contributor

Mangatt commented Jul 20, 2018

There is some mismatch with [Select] events.

<Select 
    onChange={console.log} 
    onBlur={console.log}
>
    {options}
</Select>

In this case, both events are fired, but onChange has event.target set to [Input] with appropriate attributes, but onBlur has event.target set to [Select]. Even when onBlur is set directly to [Input], event.target is still [Select].

Problem is that this makes onBlur event useless when you need handle input value onBlur in stateless components. You can't read input value or any of attributes.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 20, 2018

@Mangatt We are trying to simulate a native select. The implementation is challenging. The blur event comes from a div: https://github.com/mui-org/material-ui/blob/4bf97b52113f104174f0cd850bfc2a8fc73c2d99/packages/material-ui/src/Select/SelectInput.js#L287

@oliviertassinari oliviertassinari added the component: select This is the name of the generic UI component, not the React module! label Jul 20, 2018
@Mangatt
Copy link
Contributor Author

Mangatt commented Jul 20, 2018

Just a suggestion, wouldn't be better to pass name/value in event.target, same way that it is handled in onChange event in https://github.com/mui-org/material-ui/blob/a207808404a703d1ea2b03ac510343be6404b166/packages/material-ui/src/Select/SelectInput.js#L102?

@oliviertassinari
Copy link
Member

@Mangatt Yeah, maybe.

@oliviertassinari oliviertassinari added good first issue Great for first contributions. Enable to learn the contribution process. new feature New feature or request labels Jul 21, 2018
@oliviertassinari
Copy link
Member

@Mangatt Alright, this sounds like a good idea. Do you want to work on it? I think that we can copy #12231.

@hassan-zaheer
Copy link
Contributor

@oliviertassinari I can work on this one? Just to confirm the agreed upon solution is to pass value and name as part of the event.target?

@Mangatt
Copy link
Contributor Author

Mangatt commented Aug 10, 2018

@hassan-zaheer It would be great, since I'm unavailable to work on this issue right now. And I guess that no one else is working on this.

@hassan-zaheer
Copy link
Contributor

np I can submit a fix tonight

oliviertassinari pushed a commit that referenced this issue Aug 11, 2018
* As discussed in #12204 - added "name" to

- event.target for onBlur callback

* clone the onChange event logic
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! good first issue Great for first contributions. Enable to learn the contribution process. new feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants