Skip to content

Change behavior of BasicDatePicker when selecting a date twice in a row #24

@jalavosus

Description

@jalavosus

When selecting the same date from a BasicDatePicker twice in a row (a duplicate selection), the component resets its entire state, and clears out the selection.

From looking at the code, it seems like this behavior is supposed to happen. However, it seems counter-intuitive to me to clear the whole selection if a date is selected twice.

I can't come up with an easy workaround for this in my own code.

If I were to create a PR related to this, I could do one of two things:

  • Stop the state from resetting on a duplicate selection, and instead close or keep open the date picker according to the keepOpenOnSelect prop.
  • Add a new boolean prop (clearOnDuplicate or something to that effect), defaulting to true (the current behavior), which controls whether or not this behavior occurs in the first place. I.e:
    • clearOnDuplicate={false}: If a duplicate selection is made, nothing happens, and the date picker closes or remains open according to the value of keepOpenOnSelect.
    • clearOnDuplicate={true}: If a duplicate selection is made, the component's state is completely reset (current behavior, possible default).

Let me know what y'all think.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions