Skip to content
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

[pickers] DatePicker Popper is losing ref position (x,y) after setting a value (keyboard) #9315

Closed
2 tasks done
MorMeshulam opened this issue Jun 13, 2023 · 8 comments
Closed
2 tasks done
Labels
component: pickers This is the name of the generic UI component, not the React module! support: commercial Support request from paid users

Comments

@MorMeshulam
Copy link

MorMeshulam commented Jun 13, 2023

Order ID or Support key 💳 (optional)

3453

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

The problem in depth 🔍

I am trying to use the new version 6.7 of x-date-picker-pro and i am having an issue with
the popper that losing its relative position after setting a value.
my case ->
i am manipulating the component to be able to use both popper and input at the same time (i saw that is not the native behavior) by calling inputRef.current.focus() inside onOpen event.

This is my current implementation when i am using v5 and TextInput ->

Screen.Recording.2023-06-13.at.12.53.06.mov

This is my the new v6 with DateField (The issue) ->

Screen.Recording.2023-06-13.at.12.52.38.mov

is there any way to work with the DateField and keep the popper opened ?

Your environment 🌎

`npx @mui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.
@MorMeshulam MorMeshulam added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: commercial Support request from paid users labels Jun 13, 2023
@MorMeshulam MorMeshulam changed the title Popper is lost ref position (x,y) after setting value DatePicker Popper is losing ref position (x,y) after setting a value (keyboard) Jun 13, 2023
@LukasTy
Copy link
Member

LukasTy commented Jun 13, 2023

Could you please provide a minimal reproduction case to showcase the problem you are having?
I've tried replicating your use case and it seems to work somewhat close to how you are expecting, given your video comparisons.

@LukasTy LukasTy added status: waiting for author Issue with insufficient information component: pickers This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jun 13, 2023
@LukasTy LukasTy changed the title DatePicker Popper is losing ref position (x,y) after setting a value (keyboard) [pickers] DatePicker Popper is losing ref position (x,y) after setting a value (keyboard) Jun 13, 2023
@MorMeshulam
Copy link
Author

MorMeshulam commented Jun 14, 2023

Whenever you try to make the popper visible while typing in the input field,
will make that happens.
i doing it by manipulating the open value + set focus to the inputRef.

i think that the component doesn't support that use case.
from what i see on the MUI native DatePicker demo is a way that you can,
open the picker by clicking the icon OR use the DateField inline edit by focusing the field,
but no way to type and see the calendar popper.

am i missing something?
is it possible ?

this is a very common Date picking use case .
i will appreciate your help.

@github-actions github-actions bot removed the status: waiting for author Issue with insufficient information label Jun 14, 2023
@LukasTy
Copy link
Member

LukasTy commented Jun 14, 2023

What you are describing is not supported by our pickers out of the box.
We are following a11y guidelines in regards to the interaction behavior.

Although I've tried hacking around and based on your description, it seems that this demo does cover the use case you are describing. 🤔
We would still suggest strongly considering the a11y implications that this behavior would incur.

@MorMeshulam
Copy link
Author

MorMeshulam commented Jun 14, 2023

Thanks, your code example helped me to figure it out!

i used both textField and field (i needed field in order to manipulate sections)
apparently when you use the, both it is breaking the focus.

textField: {
value,
inputProps: renderInputProps(),
InputProps: { endAdornment: renderClearButton(value, onClear) },
label: renderLabel(),
onKeyDown,
},
// field: {
// selectedSections,
// onSelectedSectionsChange,
// unstableFieldRef: fieldRef,
// },

@MorMeshulam
Copy link
Author

MorMeshulam commented Jun 14, 2023

is it possible or even right to use them both?

just add ->

field: {
onSelectedSectionsChange: () => {}
}

to you code example and it is not working anymore

@LukasTy
Copy link
Member

LukasTy commented Jun 14, 2023

I will kindly ask you to provide a codesandbox example, where something is not working.
I tried adding the mentioned snippet and to me, it did not seem that anything has changed. I'd start by asking a different question: why are you trying to control the selected sections? Your use case does not seem to require it.

In regards to the problem shown in the video, consider checking #9285 as it also showcased a similar problem and the root cause was an issue of forgetting to forward original textField.InputProps containing the relevant ref.

@MorMeshulam
Copy link
Author

thanks,
i need to catch the year section change.
when the user type 23 on the year section i am making it to be 2023 by clicking enter/tab.
i found the best way of doing it is with the use of onSelectedSectionsChange

i think i am ok now.
thanks a lot for your help.
next time i will provide sandbox example.

@LukasTy
Copy link
Member

LukasTy commented Sep 15, 2023

Closing the issue as there does not seem to be any more open questions left to answer.
Feel free to re-open the issue or create a new one otherwise. 👌

@LukasTy LukasTy closed this as completed Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! support: commercial Support request from paid users
Projects
None yet
Development

No branches or pull requests

2 participants