Skip to content

Commit

Permalink
fix(ChipsSelect/CustomSelect): Change option key back to option.value (
Browse files Browse the repository at this point in the history
…#7276)

В момент когда делали ChipsSelect стабильным (#6206), мы поменяли key на использование option.label вместо option.value. Это не совсем правильно, так как текстовое представление label может совпадать, в то время как value должно быть уникальным.

Поменял key в ChipsInput при рендере Chips и в ChipsSelect при рендере options.
Обновил key в CustomSelect для единообразия по аналогии с ChipsSelect.
  • Loading branch information
mendrew authored and actions-user committed Aug 1, 2024
1 parent b33ea35 commit 93b7416
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const ChipsInputBase = <O extends ChipOption>({
onKeyDown={disabled ? undefined : handleListboxKeyDown}
>
{value.map((option, index) => (
<React.Fragment key={`${typeof option.value}-${option.label}`}>
<React.Fragment key={`${typeof option.value}-${option.value}`}>
{renderChip(
{
'Component': 'div',
Expand Down
2 changes: 1 addition & 1 deletion packages/vkui/src/components/ChipsSelect/ChipsSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ export const ChipsSelect = <Option extends ChipOption>({
);
}
return (
<React.Fragment key={`${typeof option.value}-${option.label}`}>
<React.Fragment key={`${typeof option.value}-${option.value}`}>
{renderOption(
{
id: dropdownItemId,
Expand Down
2 changes: 1 addition & 1 deletion packages/vkui/src/components/CustomSelect/CustomSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ export function CustomSelect<OptionInterfaceT extends CustomSelectOptionInterfac
const selected = index === selectedOptionIndex;

return (
<React.Fragment key={`${option.value}`}>
<React.Fragment key={`${typeof option.value}-${option.value}`}>
{renderOptionProp({
option,
hovered,
Expand Down

0 comments on commit 93b7416

Please sign in to comment.