Repository navigation
fix: respect disableCheckbox and checkable=false on Enter key - #693
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. WalkthroughEnter 键触发选择时, Changes键盘选择行为
Estimated code review effort: 2 (Simple) | ~8 minutes Change: Bug fix Suggested reviewers: Merge Risk:
|
|
Hi @zombieJ, a friendly ping: this is ready for review whenever you have time. Happy to adjust anything. Thanks! |
With
treeCheckable, pressing Enter on the active option in the open dropdown checked the node even when it hasdisableCheckboxorcheckable: false, which a mouse click ignores.onInternalSelecthas the guard (checkable && isCheckDisabled(node)), andisCheckDisabledreadsdisableCheckboxandcheckablefrom the node it receives. A mouse click passes the whole tree node. The Enter key handler inOptionListpassed only{ key: activeKey }, so the guard never saw those flags and the node was checked (onChangefired).The Enter handler now passes
{ ...activeEntity.node, key: activeKey }, the same node data a click has, so the existing guard applies. Nothing else changes:disabledandselectable: falsewere already handled in that handler.Test:
should not check disableCheckbox or checkable=false node with Enter keyintests/Select.checkable.spec.tsxpresses Enter on adisableCheckboxnode and acheckable: falsenode (noonChange), then on a normal node (onChangecalled with['normal']). It fails onmaster(onChangeexpected 0 calls, received 1) and passes now.npx rc-testpasses (13 suites, 188 tests), andtsc --noEmitand ESLint onsrc/OptionList.tsxare clean. Prettier reports style differences insrc/OptionList.tsxonmastertoo (not in the changed lines), so I left the formatting as is.Summary by CodeRabbit