-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[fields] Can not type into date picker after dismissing calendar picker #12652
Comments
Thank you for opening this issue, I can confirm that this is a regression. |
From what I understand of the bug, it comes from the fact that the field do not necessarily re-render when focused, so the placeholder is still rendered instead of the value (which makes it impossible to select the right section. One solution is the following diff: diff --git a/packages/x-date-pickers/src/internals/hooks/useField/useFieldV6TextField.ts b/packages/x-date-pickers/src/internals/hooks/useField/useFieldV6TextField.ts
index 90ecb24fe..a157cc083 100644
--- a/packages/x-date-pickers/src/internals/hooks/useField/useFieldV6TextField.ts
+++ b/packages/x-date-pickers/src/internals/hooks/useField/useFieldV6TextField.ts
@@ -78,6 +78,7 @@ export const useFieldV6TextField: UseFieldTextField<false> = (params) => {
const theme = useTheme();
const isRTL = theme.direction === 'rtl';
const focusTimeoutRef = React.useRef<ReturnType<typeof setTimeout>>();
+ const [, forceRender] = React.useState({});
const {
forwardedProps: {
@@ -225,12 +226,12 @@ export const useFieldV6TextField: UseFieldTextField<false> = (params) => {
clearTimeout(focusTimeoutRef.current);
focusTimeoutRef.current = setTimeout(() => {
// The ref changed, the component got remounted, the focus event is no longer relevant.
- if (!input || input !== inputRef.current) {
+ if (!input || input !== inputRef.current || readOnly) {
return;
}
- if (activeSectionIndex != null || readOnly) {
- return;
+ if (activeSectionIndex != null) {
+ forceRender({});
}
if ( Another, probably cleaner would be to investigate why |
@c1oneman: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
Steps to reproduce
Link to live example: https://stackblitz.com/edit/react-btjvds?file=Demo.tsx
Steps:
Tested on the latest 7.1.0 version, the stackblitz referenced in the docs.
Current behavior
When clicking into the date picker field, you are unable to type in the date if you have already opened the calendar popover.
Expected behavior
The value MM/DD/YYYY should populate in the date picker field after you click into the field.
Context
Users filling out a form may intentionally dismiss the calendar popover to type in a date themselves.
Your environment
npx @mui/envinfo
Chrome Version 123.0.6312.87Search keywords: date picker focus field can't type
The text was updated successfully, but these errors were encountered: