Skip to content

Conversation

jalavosus
Copy link
Contributor

@jalavosus jalavosus commented Feb 22, 2019

What kind of change does this PR introduce?
This PR is a first draft implementation of my proposal in #24.

It introduces a new prop, clearOnSameDateClick (bool), which controls whether or not the state of the datepicker component gets reset if the same date is clicked in succession.

Ex. I click the "Today" button, and then click it again.

With the default behavior (prop=true), the entire datepicker would reset (including clearing the previous selection).

If clearOnSameDateClick is set to false, the datepicker doesn't reset, and the previous selection is maintained with each successive click of the same date.

Checklist:

  • Documentation (Updated README.md and added comments clearly explaining the new behavior in datepicker.js).
  • Tests (yarn test passes)
  • Ready to be merged
  • Added myself to contributors table

Closes #24.

@vercel
Copy link

vercel bot commented Feb 22, 2019

This pull request is automatically deployed with Now.
To access deployments, click Details below or on the icon next to each push.

@codecov-io
Copy link

codecov-io commented Feb 22, 2019

Codecov Report

Merging #25 into master will decrease coverage by 0.06%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #25      +/-   ##
=========================================
- Coverage    9.75%   9.68%   -0.07%     
=========================================
  Files          13      13              
  Lines         287     289       +2     
  Branches       58      59       +1     
=========================================
  Hits           28      28              
- Misses        206     207       +1     
- Partials       53      54       +1
Impacted Files Coverage Δ
src/components/datepicker.js 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 371eac7...4ba7173. Read the comment docs.

@arthurdenner
Copy link
Owner

arthurdenner commented Feb 25, 2019

@jalavosus, great work! Thanks for adding this feature.

Can you rebase your branch and solve the conflict so I can merge it?

And feel free to add yourself to the contributors table by running the add-contributor script.

This prop, if `false`, will prevent the component's state
from resetting if the same date is clicked in succession.

So as to not break previous or expected default behavior,
the default value of this prop is `true`.
@arthurdenner arthurdenner merged commit 7f2175b into arthurdenner:master Feb 25, 2019
arthurdenner pushed a commit that referenced this pull request Feb 25, 2019
* Add clearOnSameDateSelect prop to basic datepicker.

This prop, if `false`, will prevent the component's state
from resetting if the same date is clicked in succession.

So as to not break previous or expected default behavior,
the default value of this prop is `true`.

* Add storybook entry for the clearOnSameDateClick prop
being equal to `false`.

* Updated README.md to reflect clearOnSameDateClick prop.
arthurdenner pushed a commit that referenced this pull request Feb 25, 2019
* Add clearOnSameDateSelect prop to basic datepicker.

This prop, if `false`, will prevent the component's state
from resetting if the same date is clicked in succession.

So as to not break previous or expected default behavior,
the default value of this prop is `true`.

* Add storybook entry for the clearOnSameDateClick prop
being equal to `false`.

* Updated README.md to reflect clearOnSameDateClick prop.
@arthurdenner
Copy link
Owner

The features in your PRs are now published in the version 1.9.0. 🎉

Thanks once again, @jalavosus!

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

Successfully merging this pull request may close these issues.

Change behavior of BasicDatePicker when selecting a date twice in a row
3 participants