refactor(RangePicker): centralize interaction flow#994
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
React Doctor could not complete this scan.
Reviewed by React Doctor for commit |
❌ Deploy failed
📋 Build log (last lines)🤖 Powered by surge-preview |
|||||||||
There was a problem hiding this comment.
Code Review
This pull request refactors focus and value change handling in the RangePicker component by introducing the useFocusControl and useRangeValueChange hooks. These hooks streamline the coordination of calendar value updates, partial/final submissions, and focus/blur states across multiple fields. The feedback suggests a critical fix in useRangeValueChange to allow smooth field switching when needConfirm is false and the previous field is empty, as well as adding optional chaining to selectorRef.current accesses in RangePicker.tsx to prevent potential runtime errors.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
|
||
| // ============================= Utils ============================= | ||
| /** Check whether the target is the container itself or inside it. / 判断目标是否为容器自身或其子元素。 */ | ||
| function containsElement(container: Element | null, target: EventTarget | null) { |
There was a problem hiding this comment.
这个函数直接在 isTargetInContainers 里内联掉,不要额外写个函数

Summary
PickerTrigger.onCloseresponsible only for popup visibilityMotivation
RangePicker currently spreads part-submit and reset behavior across event handlers and an effect. This refactor prepares a single event-driven decision point for confirm and non-confirm flows, following the behavior discussed around #966.
Impact
This changes RangePicker's internal interaction handling only. The existing
useRangeValuehook remains responsible for value validation and final submission.Validation
ut lint:tscrc-test tests/new-range.spec.tsx --runInBand— 65 passedrc-test tests/range.spec.tsx --runInBand— 110 passed, 1 skipped, 1 failedpanel should keep open when nextValue is empty; the final panel selection currently overwrites the start field after switching back to itThis PR remains a draft while that compatibility case is being resolved.