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] Set the onChange's event.target.value #14

Open
michaldudak opened this issue Sep 21, 2022 · 7 comments
Open

[Select] Set the onChange's event.target.value #14

michaldudak opened this issue Sep 21, 2022 · 7 comments
Labels
component: select This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature

Comments

@michaldudak
Copy link
Member

As noted in mui/material-ui#34408 (comment), it's worth ensuring that the event object in Unstyled Select's onChange method has a target property with a valid value property.

@michaldudak michaldudak changed the title [Select][base] [Select][base] Set the onChange's event.target.value Sep 21, 2022
@harsh5902
Copy link

shall i work on this issue?

@michaldudak
Copy link
Member Author

Sure, go ahead!

@jesrodri
Copy link

@harsh5902 are you still working on this? if not, can I take it?

@harsh5902
Copy link

yes i am still working on it.

@michaldudak michaldudak assigned michaldudak and unassigned harsh5902 Apr 27, 2023
@michaldudak
Copy link
Member Author

I have investigated the problem in more depth. In the case of Select, setting the event.target.value may not work the best because:

  • HTMLSelectElement.value is defined as a string. In our case, this could be any object.
  • In the case of select multiple, the value contains only the first selected element. The whole collection is available under the selectedOptions, which is a set of HTMLOptionElement instances. This is not available in the case of our custom Select.

I'd like to wait and see if this becomes a problem in real-world applications. When we see concrete examples of how this should work, we may be able to think of the right solution. Until then, I'm putting it on hold.

A side note: neither Headless UI nor Radix UI provides the event object in their selects' change handlers.

@michaldudak michaldudak removed their assignment Apr 27, 2023
@michaldudak michaldudak changed the title [Select][base] Set the onChange's event.target.value [Select][base-ui] Set the onChange's event.target.value Aug 18, 2023
@michaldudak michaldudak transferred this issue from mui/material-ui Feb 27, 2024
@michaldudak michaldudak changed the title [Select][base-ui] Set the onChange's event.target.value [Select] Set the onChange's event.target.value Feb 27, 2024
@michaldudak michaldudak added component: select This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature labels Feb 27, 2024
@Sen-442b
Copy link

@michaldudak slightly unrelated, but is there a similar rationale behind not supporting e.target.name as well?

@michaldudak
Copy link
Member Author

We are considering changing this API in the new version of the Select but nothing is set in stone yet.

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! enhancement This is not a bug, nor a new feature
Projects
Status: Backlog
Development

No branches or pull requests

4 participants