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

ui-core: nuke value in Select #538

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

ui-core: nuke value in Select #538

wants to merge 1 commit into from

Conversation

emersion
Copy link
Member

@emersion emersion commented Sep 24, 2024

We don't really need a value here, we can just use indexes instead. This makes it easier to use Select for small lists (e.g. 3 static choices) and simplifies the code.

Discussion: OpenRailAssociation/osrd#8838 (comment)

@emersion emersion requested a review from a team as a code owner September 24, 2024 13:21
We don't really need a value here, we can just use indexes instead.
This makes it easier to use Select for small lists (e.g. 3 static
choices) and simplifies the code.

Signed-off-by: Simon Ser <[email protected]>
<option key={getOptionValue(option)} value={getOptionValue(option)}>
{getOptionLabel(option)}
</option>
/* eslint-disable-next-line react/jsx-key */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We loose the key here, but since these lists are quite short I don't believe it matters.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we will have a warning in console each time we use the Select component ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s a generic component, We don’t know who is going to use it, and it could be a select of any size.
Besides, I think even with smaller lists react can get confused and mix up elements between renders if you don’t use keys.

@emersion emersion self-assigned this Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants