-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[pickers] Improve DOM event management on useField
#5901
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
Conversation
These are the results for the performance tests:
|
useField
I have quickly played with this problem. Applying this diff on HEAD seems to solve the problem too: diff --git a/packages/x-date-pickers/src/internals/hooks/useField/useField.ts b/packages/x-date-pickers/src/internals/hooks/useField/useField.ts
index 0f5642aa0..3447f0a51 100644
--- a/packages/x-date-pickers/src/internals/hooks/useField/useField.ts
+++ b/packages/x-date-pickers/src/internals/hooks/useField/useField.ts
@@ -317,8 +317,13 @@ export const useField = <
});
const handleInputFocus = useEventCallback(() => {
- // TODO: Avoid applying focus when focus is caused by a click
- updateSelectedSections(0, state.sections.length - 1);
+ setTimeout(() => {
+ if (inputRef.current.selectionEnd - inputRef.current.selectionStart === 0) {
+ handleInputClick();
+ } else {
+ updateSelectedSections(0, state.sections.length - 1);
+ }
+ })
});
const handleInputBlur = useEventCallback(() => updateSelectedSections()); |
The current implementation introduces the following regression. Screen.Recording.2022-08-26.at.14.15.06.mov |
@LukasTy I can implement it of course |
Done |
The approach we went for do not work on Android |
https://deploy-preview-5901--material-ui-x.netlify.app/x/react-date-pickers/date-field/