Material-ui: [DateRangePicker] Allow same date selection

Created on 16 Sep 2020  路  6Comments  路  Source: mui-org/material-ui

               <DateRangePicker
                  startText="Created From"
                  endText="Created To"
                  allowSameDateSelection={true}
                  value={[
                    searchCriteria.beginDate,
                    searchCriteria.endDate,
                  ]}
                  onChange={}
                  renderInput={(startProps, endProps) => (
                    <React.Fragment>
                      <TextField
                        {...produce(startProps, (draft) => {
                          draft.helperText = '';
                        })}
                      />
                      <DateRangeDelimiter> to </DateRangeDelimiter>
                      <TextField
                        {...produce(endProps, (draft) => {
                          draft.helperText = '';
                        })}
                      />
                    </React.Fragment>
                  )}
                />

image

i think the issue is in the validateDateRange function. This function not use the allowSameDateSelection to pass the validate of utils.isBefore(range[0], range[1])

bug 馃悰 DateRangePicker

Most helpful comment

I have this problem also. I would appreciate if it could be fixed as fast as possible. Thanks!

All 6 comments

I have this problem also. I would appreciate if it could be fixed as fast as possible. Thanks!

Please fix this. We need it!

This project is not supported anymore, it is moving to the material-ui/core https://github.com/mui-org/material-ui/pull/22692 but the PR is floating.

I`ll add a mention about this in readme

It looks like we should remove the allowSameDateSelection prop. The prop is described as:

https://github.com/mui-org/material-ui/blob/35e674311a97a72da806c04ba61e44fae79fdfee/packages/material-ui-lab/src/DesktopDateRangePicker/DesktopDateRangePicker.tsx#L29-L33

As far as I know, there are no valid use cases for it, no matter a date picker, time picker, date range picker, etc. One thing that we have seen in the past is the capability to control the range that can be selected, this is a different problem and require a broader solution.

@oliviertassinari Is this a matter of applying the old PR to this repository or is there more to it?

@havgry I can't say. I didn't look at the pull request in detail.

Was this page helpful?
0 / 5 - 0 ratings