Repository navigation
fix: depend on rawValues directly in OptionList selection callbacks - #1266
mokshupadhyay wants to merge 1 commit into
Conversation
|
@mokshupadhyay is attempting to deploy a commit to the React Component Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. Walkthrough
Changes选中状态更新
Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix · Severity of issue fixed: Low Suggested reviewers: Merge Risk:
|
|
Hi @yoyo837, a friendly ping: this is ready for review whenever you have time. Happy to adjust anything. Thanks! |
|
CI failed. |
|
Thanks for checking. The failing job is not caused by this change: it fails in 3 suites (Tags, Combobox, Select) with "Outdated guide link: The snapshot guide link at the top of this snapshot is outdated" (expected |
OptionListmemoizesisSelectedandisAriaSelected(they decide whether an option is shown as selected) with the dependency[...rawValues].toString(). Two different selections can have the same string:1and the string'1'(both"1"), and['a,b', 'c']and['a', 'b,c'](both"a,b,c").When the selection changes between such values, the dependency does not change, so the callback keeps the old
rawValuesand the list shows the previous selection.Result of the new tests, from the original source (the option list opened with
virtual={false}):value={1}tovalue="1"rc-select-item-option-selected(stale)value={['a,b', 'c']}tovalue={['a', 'b,c']}The fix lists
rawValuesitself in the dependencies ofisSelectedandisAriaSelected.rawValuesis already memoized inSelect(a newSetis created only when the selected values change) and is already a dependency of the select context, so the callbacks are not recreated more often than their consumers.Tests: added two tests in
tests/OptionList.test.tsx; both fail on the original source and pass now.npm testpasses (24 suites, 468 tests),npm run tscis clean, andnpm run lintreports 0 errors (the changed files go from 7 warnings on the base to 3).Summary by CodeRabbit