-
-
Notifications
You must be signed in to change notification settings - Fork 318
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: fix panel not switch when select date with open is true #663
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov Report
@@ Coverage Diff @@
## master #663 +/- ##
=======================================
Coverage 99.05% 99.05%
=======================================
Files 56 56
Lines 2426 2430 +4
Branches 720 734 +14
=======================================
+ Hits 2403 2407 +4
Misses 21 21
Partials 2 2
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
这个说明一下思路? |
好,当前如果 open、defaultOpen 为 true 时,时间选择面板默认是打开的,相较于点击输入框打开时间选择面板缺少了设置 |
@@ -43,6 +43,10 @@ export default function useRangeOpen( | |||
] { | |||
const [firstTimeOpen, setFirstTimeOpen] = React.useState(false); | |||
|
|||
const [afferentOpen, setAfferentOpen] = useMergedState(defaultOpen || false, { |
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.
你没发现这样子就和下面 mergedOpen 一样了么 😄
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.
对的,这里我想让 defaultOpen 首次参与 open 的计算,后续不会影响到 afferentOpen 这个值,跟 mergedOpen 不同的是 只有一处主动调用了 set 方法,后续状态变更时我这边测出来 afferentOpen 的值和 mergedOpen 的值是不一致的 😂
ref.current?.focus(); | ||
}); | ||
} else { | ||
setMergedOpen(false); | ||
} | ||
} else { | ||
setMergedOpen(false); | ||
setAfferentOpen(false); |
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.
对,受控关闭的话是不会走到这里,这里是考虑到在 defaultOpen 为 true 的情况下,选择完日期点击外部内容触发关闭后会走到这里,如果不设置为 false 的话后续 defaultOpen 因为会一直为 true,此时的状态应该是不对的。
close ant-design/ant-design#43802