-
-
Notifications
You must be signed in to change notification settings - Fork 319
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: interacting with footer components closes the date selection panel #683
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov Report
@@ Coverage Diff @@
## master #683 +/- ##
=======================================
Coverage 98.94% 98.94%
=======================================
Files 56 56
Lines 2457 2460 +3
Branches 734 735 +1
=======================================
+ Hits 2431 2434 +3
Misses 24 24
Partials 2 2
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
目前还有一些问题: |
@@ -326,6 +327,7 @@ function InnerPicker<DateType>(props: PickerProps<DateType>) { | |||
const [inputProps, { focused, typing }] = usePickerInput({ | |||
blurToCancel: needConfirmButton, | |||
changeOnBlur, | |||
hasExtraFooter: !!renderExtraFooter, |
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.
usePickerInput 可以直接接收 renderExtraFooter 吗,不需要用 hasExtraFooter
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.
里面主要用来做逻辑判断应该用不到 renderExtraFooter 方法,因此我在外面判断是否存在。
onSubmit: () => void | boolean; | ||
onCancel: () => void; | ||
onFocus?: React.FocusEventHandler<HTMLInputElement>; | ||
onBlur?: React.FocusEventHandler<HTMLInputElement>; | ||
}): [React.DOMAttributes<HTMLInputElement>, { focused: boolean; typing: boolean }] { | ||
const [typing, setTyping] = useState(false); | ||
const [focused, setFocused] = useState(false); | ||
const [outside, setOutside] = useState(true); |
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.
这个改变需要 render 吗,可以用 useRef 吗
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.
对,只需要阻塞一下 blur。
@@ -152,6 +155,11 @@ export default function usePickerInput({ | |||
const target = getTargetFromEvent(e); | |||
const clickedOutside = isClickOutside(target); | |||
|
|||
if (hasExtraFooter) { |
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.
这种零碎逻辑太多了不好,感觉是写个 RFC 让 ConfigProvider 支持关闭逻辑。例如默认是 blur 关闭,也可以设置成点击外部关闭。这样就不管你是哪个组件,都是一样的逻辑。
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.
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.
另外,点击 renderExtraFooter 位置元素,应该不属于 blur 啊?也没有离开 Picker 啊?为什么会触发 blur 呢?
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.
触发了 input 的 blur 。
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.
还有 Select 的自定义 render,也需要阻止冒泡。按理说点击自定义添加的按钮或者 Input,应该不属于 Select 的选中,不应该关闭 Select 的下拉框的
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.
对的,所以这里可以整理一个 RFC 出来。
close ant-design/ant-design#33125
目前还有一些问题:
1、input 需要设置 stopPropagation 才能聚焦,是否要在 footer 处集成;
2、select 等需要点击临时元素的,需要设置 getPopupContainer={(e) => e.parentElement}。