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

added reopenPickerOnClearDates prop #75

Merged
merged 1 commit into from
Sep 15, 2016
Merged

Conversation

agupta93
Copy link

@agupta93 agupta93 commented Sep 11, 2016

This PR is in response to the issue #68 . As requested a prop reopenPickerOnClearDates has been added which governs whether the picker will be shown when clear is clicked.

By default the value is set to false.

@ljharb ljharb added the semver-major: breaking change A non-backwards-compatible change; anything that breaks code - including adding a peerDep. label Sep 11, 2016
@ljharb
Copy link
Member

ljharb commented Sep 11, 2016

Naming the prop in this way makes it a breaking change - it'd be preferred to find a way to name the (default false) prop so that the reopen behavior is the default.

@agupta93
Copy link
Author

@ljharb okay will do the same

@ljharb ljharb added the semver-minor: new stuff Any feature or API addition. label Sep 11, 2016
@agupta93
Copy link
Author

@ljharb PR updated please check

@@ -223,8 +224,11 @@ export default class DateRangePicker extends React.Component {
}

clearDates() {
this.props.onDatesChange({ startDate: null, endDate: null });
this.props.onFocusChange(START_DATE);
const {onDatesChange, reopenPickerOnClear, onFocusChange} = this.props;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curly braces need spaces inside them

@agupta93
Copy link
Author

@ljharb made all the changes recommended by you please check

@ljharb ljharb removed the semver-major: breaking change A non-backwards-compatible change; anything that breaks code - including adding a peerDep. label Sep 11, 2016
@ljharb
Copy link
Member

ljharb commented Sep 11, 2016

Thanks, LGTM! It'd be great to also add an example for it in the storybook.

@agupta93
Copy link
Author

agupta93 commented Sep 12, 2016

@ljharb there is already a case for clear button would modify the same right according to the new feature added. One more thing is there a channel or IRC channel where the developers of this repo can be contacted for doubts in the code?

@agupta93 agupta93 changed the title added reopenPickerOnClear prop which when true opens the date picker added hidePickerOnClear prop which when true hides the date picker Sep 12, 2016
@agupta93
Copy link
Author

added the example in storybook also

@@ -43,6 +43,7 @@ const defaultProps = {
numberOfMonths: 2,
showClearDates: false,
disabled: false,
hidePickerOnClear: false,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you click the clear button now when the datepicker is open, I don't think this will actually hide the picker so this prop name is a misnomer. Something like dontReopenPickerOnClear maybe makes more sense... or even in this case, it might be worth it to have the semver breaking change of reopenPickerOnClear. What do you think @ljharb?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're comfortable with a breaking change, then sure - that might be better.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be fine. We can couple the release with #53 for 3.0.0. I think, semantically, reopenPickerOnClearDates seems like a better name

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ljharb and @majapw so is it final then the prop name would be reopenPickerOnClearDates whose default value would be false?

@majapw
Copy link
Collaborator

majapw commented Sep 12, 2016

Thanks for the example. In addition to my comment about the naming, we'll definitely need to add a bit to the README about this prop.

We don't have a channel for discussing this code yet, but opening up an issue is probs the easiest way to get in touch.

@agupta93
Copy link
Author

@majapw yaa i saw your comment, whatever name you guys finalize wont be a major change so once it finalized will change the name and add the corresponding readme regarding it. This would be my first commit to the library and would like to solve other open issues as well.

I asked for some channel so as to ficilitate some doubts that i might have in the code :)

@agupta93
Copy link
Author

@majapw and @ljharb as discussed added a prop reopenPickerOnClearDates which defaults to false which means that no picker is shown by default on clear

Added a corresponding example in the storybook and also added the README for the same

@majapw
Copy link
Collaborator

majapw commented Sep 13, 2016

Hi @agupta93! It looks like this is breaking the onFocusChange test now (which makes sense). If you could address that and maybe even add a test for this new prop, that would be awesome. :) We can merge it in after the tests change.

Can you also rebase locally and push it up instead of hitting the update branch button? That would help immensely in keeping our tree clean.

@ljharb ljharb added the semver-major: breaking change A non-backwards-compatible change; anything that breaks code - including adding a peerDep. label Sep 13, 2016
@majapw majapw removed the semver-minor: new stuff Any feature or API addition. label Sep 13, 2016
@agupta93
Copy link
Author

@majapw corrected the build error and added the test for the same please check :)

@@ -154,17 +154,32 @@ describe('DateRangePicker', () => {
});

describe('#clearDates', () => {
describe('props.reopenPickerOnClearDates', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So probably the structure of these tests should look something like:

describe('#clearDates', () => {
  describe('props.reopenPickerOnClearDates is truthy', () => {
    describe('props.onFocusChange', () => {
      it('is called once', () => {
        ...
      });

      it('is called with arg START_DATE', () => {
        ...
      });
  });

  describe('props.reopenPickerOnClearDates is falsey', () => {
    describe('props.onFocusChange is not called', () => {
      ...
    });
  });
});

Some of these tests are duplicates right now.

@majapw
Copy link
Collaborator

majapw commented Sep 13, 2016

Right now the travis build is failing on some linting rules! You should address those and also run git rebase origin/master before you push back up to your remote branch. ✌️

@agupta93
Copy link
Author

@majapw all changes done as asked hope everything looks fine now ✌️

Copy link
Collaborator

@majapw majapw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Is there any way you can squash your five commits into one single commit? I'll merge it in after that.

@agupta93
Copy link
Author

@majapw commits squashed !!

@majapw majapw merged commit 1de63ba into react-dates:master Sep 15, 2016
@majapw majapw changed the title added hidePickerOnClear prop which when true hides the date picker added reopenPickerOnClearDates prop Sep 15, 2016
@jamhall
Copy link

jamhall commented Sep 15, 2016

@agupta93 ! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-major: breaking change A non-backwards-compatible change; anything that breaks code - including adding a peerDep.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants