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

In inline mode, when current day is disable, opening the picker is select the first enabled day. #1300

Closed
ChanaKra opened this issue Sep 2, 2019 · 4 comments

Comments

@ChanaKra
Copy link

ChanaKra commented Sep 2, 2019

Environment

Tech Version
@material-ui/pickers 3.2.4
material-ui 4
React 16.8
Browser chrome
Peer library moment

Steps to reproduce

  1. Create a picker with variant="inline"
  2. Add shouldDisableDate that disable current day.
    (with moment, for example: shouldDisableDate={(date)=>date.isSame(moment(),'day')} )
  3. Open the picker, and close it without selecting any date.

Expected behavior

No date is selected.

Actual behavior

When open the picker, the first enabled day is selected.

Live example

https://codesandbox.io/s/material-ui-pickers-usage-demo-qxylf

@dmtrKovalenko
Copy link
Member

It is by design.

@ChanaKra
Copy link
Author

ChanaKra commented Sep 4, 2019

It's not consistent.
To clarify, The problem is that in this case, the first enabled day is not only focused but also the onChange & onAccept functions are invoked.
If you open the picker when the current day is enable - the current day get focused, but onChange & onAccept are not invoked.

In addition, it's only occurs in inline mode.

@dmtrKovalenko
Copy link
Member

dmtrKovalenko commented Sep 4, 2019

Yeah, I know. We probably can consider changing it in #1293. But right now if current day is disabled picker will automatically select the closest one.
But for inline mode any selection triggers onChange to be called.

What behavior you want to see there? Highlight the disabled date?

@ChanaKra
Copy link
Author

ChanaKra commented Sep 5, 2019

In inline mode, any selection triggers onChange. but open and close picker isn't selection.
For example, when the field is empty, open the picker doesn't select current date.

I expect that the closest enable date will be highlight, but not update the value,
just like when highlight current date:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants