[pickers] Improve DOM event management on useField#5901
Merged
Conversation
|
These are the results for the performance tests:
|
useField
Member
|
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()); |
Member
|
The current implementation introduces the following regression. Screen.Recording.2022-08-26.at.14.15.06.mov |
Member
Author
|
@LukasTy I can implement it of course |
Member
Author
|
Done |
LukasTy
approved these changes
Aug 26, 2022
Member
Author
|
The approach we went for do not work on Android |
alexfauquette
pushed a commit
to alexfauquette/mui-x
that referenced
this pull request
Sep 20, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
https://deploy-preview-5901--material-ui-x.netlify.app/x/react-date-pickers/date-field/