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

[DateRangeInput] external controls to .open() or .close() date picker popover #1053

Closed
haosharon opened this issue May 1, 2017 · 4 comments

Comments

@haosharon
Copy link
Contributor

We want to trigger the datepicker to be open or closed sometimes based on focus events.

It's a bit cumbersome to track popoverState externally and pass that down because there's a lot of complex logic that goes into computing the date picker open state - it would be nice to just be able to trigger actions (based on focus / blur etc)

@cmslewis cmslewis changed the title [DateRangePicker] external controls to .open() or .close() date picker popover [DateRangeInput] external controls to .open() or .close() date picker popover May 2, 2017
@cmslewis cmslewis self-assigned this May 2, 2017
@adidahiya
Copy link
Contributor

adidahiya commented May 3, 2017

This feels a little weird... it sounds like a new API to allow users to switch between uncontrolled & controlled mode during the component's lifecycle. I'd be curious to see what the code looks like with and without this new API and how this changes the space of possible configurations that need to be unit tested.

@cmslewis
Copy link
Contributor

cmslewis commented May 3, 2017

Agree that it feels weird, and I'm definitely open to feedback (cc @haosharon for additional context). Desired workflow is:

  1. Click on a button.
  2. Reveal a DateRangeInput with the popover initially open.
  3. Defer to default (i.e. uncontrolled) popover open/close behavior thereafter.

You could accomplish this with a manual startInputRef.focus() from a parent component in componentDidUpdate, or you could set popoverProps.isOpen={true} and then hope that onInteraction will actually be invoked whenever the popover's open/close state would change (this isn't the case now but is being fixed in #1046). Maybe those approaches alone will be sufficient?

@haosharon
Copy link
Contributor Author

Yea - we are able to accomplice [1-3] with a manual startInputRef.focus(). However, for the sake of consistency we also expect the button to be able to close the popover (so that users can toggle it open/close).

The absolute correct solution is to control it ourselves, but my worry is the code to enforce that in DateRangePicker will be very brittle because there seems to be some complicated interactions between state.isOpen and popover.onInteraction

@adidahiya
Copy link
Contributor

Decided against this in #1055. The recommendation here is to get a ref on the input and call setState() on your own, which is exactly what these instance methods would've done anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants