question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NSelect: no way to know the group of an option

See original GitHub issue

This function solves the problem (这个功能解决的问题)

If multiple SelectOption in different SelectGroupOption have the same value, there is no way to distinguish which one the user have selected.

This problem happens with this really common use case:

  • We fetch list A, B and C from API
  • Each list have their own id auto increment (dedicated table in database) and so there is the same ids in each list
  • We want to use each list as a SelectGroupOption in the same NSelect
  • Because there is the same value (aka id) 1 (for example) in list A, B and C, we have no way to know which SelectOption the user have selected 😭

Expected API (期望的 API)

A very flexible way of handling that could be a new option-as-value boolean prop.

Once set to true, the value prop (and corresponding update:value event) while now deal with the whole SelectOption object instead of only the value. Because it’s an object, it become easy to add a group property which contains the corresponding SelectGroupOption key (or even the whole SelectGroupOption object after all 🤷‍♂️).

In addition, if the developer provides extra properties to SelectOption objects, he will be able to better identify which one is selected based on that extra properties.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
07akionicommented, Sep 11, 2022

onUpdate:value will pass original option as the second param.

1reaction
M1CK431commented, Sep 12, 2022

onUpdate:value will pass original option as the second param.

😱 😱 😱 Hoooo I’m sooooo sorry! I miss that part in the documentation!! I apology for the useless noise. Thanks a lot for your quick answer and patience 🤗 ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

label - HTML how to group options in a select without using ...
What you can do is move the class from the optgroup to its options, then move all the options directly under the select,...
Read more >
<optgroup>: The Option Group element - MDN Web Docs
The HTML element creates a grouping of options within a element. ... attribute is set, none of the items in this option group...
Read more >
H85: Using optgroup to group option elements inside a select
Check the set of options within a selection list to see if there are groups of related options. If there are groups of...
Read more >
Microsoft Access: How to Create Option Groups for ... - YouTube
Only one option in an option group can be selected at a time. Once you have the Option Group created, learn how to...
Read more >
Setting up and using an Option Group in Access ~ DataPig
How to set up and use the OptionGroup control, familiarize the developer ... In this example, Select Case is used to see what...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found