-
Notifications
You must be signed in to change notification settings - Fork 142
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
fix(MultiComboBox): item.labelがReactNodeだった場合のitemの比較を内部の文字列によって行うように #5191
Conversation
commit: |
@@ -468,7 +462,7 @@ const ActualMultiComboBox = <T,>( | |||
className={selectedListStyle} | |||
> | |||
{selectedItems.map((selectedItem, i) => ( | |||
<li key={`${selectedItem.label}-${selectedItem.value}`}> | |||
<li key={selectedItem.value}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
valueがitems内で一意(valueが同じでlabelが違うitemは無い)という前提を置いたので、keyの設定にlabelは必要ないはず
また、JSX.Elementが渡されると [Object Object]
が展開されてしまうので修正しました。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! ありがとうございます!!
const matchedSelectedItem = selectedItems.find( | ||
(item) => item.label === selected.label && item.value === selected.value, | ||
) | ||
const matchedSelectedItem = selectedItems.find((item) => item.value === selected.value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
選択済みスタイルについての修正はこちらも確認できました!ありがとうございます!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
いただいた指摘について対応いたしました!
const matchedSelectedItem = selectedItems.find( | ||
(item) => item.label === selected.label && item.value === selected.value, | ||
) | ||
const matchedSelectedItem = selectedItems.find((item) => item.value === selected.value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9e72b87
to
e678fb1
Compare
テスト落ちてますが、テストの意図するところが不明なので確認中です |
failしているテストケースについて、blameしてみたところこのPRが見つかりました。 |
これは大体そうだろうなぁと思いつつ、たまにあるし落とすべきかどうかちょっと迷いますね... 俺個人の意見としては
辺りで可能なら堅い判定したほうがいいんじゃないかな〜派です |
良さそう! |
なるほど、アリだと思います〜 |
c96c364
to
01b0af2
Compare
a0d1da6
to
d59de7c
Compare
d59de7c
to
878d6f5
Compare
@AtsushiM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
関連URL
https://kufuinc.slack.com/archives/C06KVP5PL23/p1734060131150619
概要
close #5190
MultiComboBoxのitem同士が同一かどうかの判定でlabelも参照されているが、labelに設定できるJSX.Elementは等価であっても等値ではない場合がありうるので、label同士の === による判定が意図通りになるかはアプリケーションの実装による。
この判定が意図通りにならない場合、同じアイテムを複数回選択できてしまう・一度選択したアイテムを選択解除できないなどの問題が発生しそう
変更内容
valueがitems内で一意(valueが同じでlabelが違うitemは無い)という前提を置き、MultiComboBox内でitem同士が同一かどうかの判定を行っていた部分でlabelも参照するのをやめました。item.labelがReactNodeだった場合のitemの比較を内部の文字列によって行うようにしました。
確認方法