Material-ui-pickers: Respect if date value is set as null

Created on 25 Jul 2019  路  8Comments  路  Source: mui-org/material-ui-pickers


A GIF or MEME to give some spice of the  internet

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
I'm setting up a page for filtering content on my site, and filtering by day is pretty obvious and easy. However then I want to stop filtering by date, as such set the value of the datepicker to null, and it just sets the value to today instead, but that doesn't work as today is also a filterable value.

Describe the solution you'd like
Have the datepicker support no day having been selected.

Describe alternatives you've considered
Unmounting and hiding the datepicker, and have the user actually mount it when they want to set a date, and then unmounting it again if they want to clear the date, but this seems overkill.

Additional context
I am using an inline datepicker with only specific dates viable (days where content is actually available) I don't know if that makes any difference.

image
As you can see there isn't even any content on today (the 25th), and yet it's still highlighted.

This issue seems to be related, though not a feature request as far as I can see.

https://github.com/mui-org/material-ui-pickers/issues/774

bug 馃悰

All 8 comments

You can pass an undefined. This will render something like Unknown in the text field

I tried it, it didn't change anything, but then, there isn't a text field, as I'm using an inline calendar.

Sorry for long response. This is something for the next major version. Because of breaking changee

I'm interested in this feature as well. A lot of my dates are optional and I would like to fully clear the picker box. passing clearable as an attribute and clicking it invokes the onChange function with null, but the picker still shows today's date.

not only null , undefined too

@kerosan We don't support undefined. undefined will be treated as unparsed value, so it will be like new Date(undefined) === new Date()

+1 for leaving undefined out of the equation. This will be helpful to be consistent with the core and if we want to support a default value (uncontrolled). See useControlled.js.

This PR was closed by #1770
Originally duplicate of #1613

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Harasz picture Harasz  路  3Comments

StevenRasmussen picture StevenRasmussen  路  3Comments

harvitronix picture harvitronix  路  3Comments

idrm picture idrm  路  3Comments

killjoy2013 picture killjoy2013  路  3Comments