fix: ensure consistency between controlled and uncontrolled logic #685
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
close ant-design/ant-design#44992 (comment)
问题背景:
在该 PR 之前如果 RangePicker 的 open 设置为 true,因为没有初始化 nextActiveIndex,所以根据 afferentOpen 和 index 等判断 nextActiveIndex,但是这样会导致 nextActiveIndex 永远不会是 null,因此永远不会触发关闭时间选择面板的逻辑(不会触发 onOpenChange)。
该 PR 的作用是当 RangePicker 处于选择完日期也就是可关闭状态时触发关闭选择时间面板的逻辑(会触发 onOpenChange),当 open 受控变成 false 时,需要将 focus 动画取消,并且由于 mergedActivePickerIndex 会先改变因此需要改回去。