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

[DateInput/DateRangeInput] Commit typed value on 'Enter' key press #1825

Merged
merged 9 commits into from
Dec 8, 2017

Conversation

cmslewis
Copy link
Contributor

Fixes #1798

Checklist

  • Include tests

Changes proposed in this pull request:

  • DateInput and DateRangeInput now save the typed value(s) on Enter.
    • They also move/transfer the focus state appropriately.

Reviewers should focus on:

  • The tests don't corroborate my understanding of what should be happening. Maybe I just need to sleep on it. I've commented or omitted some checks in the meantime.
  • Idea for followup: Revert to the old value on Esc? Thoughts?
  • Does controlled mode look good?

Screenshot

DateInput

2017-11-20 02 04 30

DateRangeInput

2017-11-20 02 04 58

@blueprint-bot
Copy link

Fix test

Preview: documentation

@llorca
Copy link
Contributor

llorca commented Nov 21, 2017

does this PR change any interaction?

+1 on reverting to previous value on Esc, if current value hasn't been submitted

@cmslewis
Copy link
Contributor Author

@llorca no, it should be strictly additive.

@blueprint-bot
Copy link

Merge branch 'master' into cl/1798-dri-enter-key

Preview: documentation

const nextDate = fromMomentToDate(nextValue);
this.handleDateChange(nextDate, true);
this.inputRef.blur();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, need to do this.safeInvokeInputProp("onKeyDown", e);.

Copy link
Contributor

Choose a reason for hiding this comment

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

@cmslewis is this comment still relevant?

Copy link
Contributor

@giladgray giladgray left a comment

Choose a reason for hiding this comment

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

looks good but there are some unresolved comments from you @cmslewis

Copy link
Contributor

@giladgray giladgray left a comment

Choose a reason for hiding this comment

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

actually, not a fan of the blur behavior.

const nextValue = this.createMoment(this.state.valueString);
const nextDate = fromMomentToDate(nextValue);
this.handleDateChange(nextDate, true);
this.inputRef.blur();
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 this .blur() feels intuitively wrong, as it kills the focus flow: I can't hit enter and then tab to move to the next form input.

can we do everything else but simply not blur? same goes for DRI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I buy that.

@blueprint-bot
Copy link

Fix blur interactions

Preview: documentation

@cmslewis cmslewis dismissed giladgray’s stale review November 29, 2017 00:51

Addressed blur issues

@cmslewis
Copy link
Contributor Author

@giladgray is this good to merge?

@giladgray
Copy link
Contributor

@cmslewis pressing enter in DateInput does not expand to full date. works great for DRI though.

@adidahiya
Copy link
Contributor

pressing enter in DateInput does not expand to full date

seems fine to address in a follow up. current behavior seems fine to me. @erinmarchand @LindsayWard @dalessi can you verify in the "documentation" link above?

@giladgray
Copy link
Contributor

wait @adidahiya how is this fine to merge? it literally doesn't work properly in one of the title use cases.

@adidahiya
Copy link
Contributor

adidahiya commented Dec 5, 2017

It seems to address the original intent of the filed issue though. Once you type something in DateInput, you get it committed when you blur out of the input (the popover gets closed, which suggests to the user that something worked -- this was not the case before this PR). Seems reasonable in most cases, and we can make further adjustments if we get more feedback. But I'm also cool with waiting to hear from the people tagged in my last comment ^

@llorca
Copy link
Contributor

llorca commented Dec 5, 2017

Check out this GIF:
screen recording google chrome
What's good: in both DI and DRI, the date picker activates with the date typed in the field
What's not good: DRI updates the input value on enter, DI doesn't. Instead, DI updates the input value on blur.

Not a fan of that inconsistency, as @giladgray pointed out.

llorca
llorca previously requested changes Dec 5, 2017
Copy link
Contributor

@llorca llorca left a comment

Choose a reason for hiding this comment

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

DI should update input value on enter, just like DRI. It currently happens on blur

@cmslewis
Copy link
Contributor Author

cmslewis commented Dec 8, 2017

@llorca @adidahiya @giladgray Sorry for the delay. Should be good to go now.

@blueprint-bot
Copy link

Format the date string on Enter in DateInput

Preview: documentation | landing | table

@adidahiya
Copy link
Contributor

nice, lgtm 👍

@cmslewis cmslewis dismissed llorca’s stale review December 8, 2017 17:56

Addressed comments

@cmslewis cmslewis merged commit 826fbc7 into master Dec 8, 2017
@cmslewis cmslewis deleted the cl/1798-dri-enter-key branch December 8, 2017 17:56
cmslewis added a commit that referenced this pull request Dec 13, 2017
…1825)

* DateInput now saves on Enter

* DateRangeInput now saves on Enter

* Write DateInput tests, fix locale bug

* Tests + bug fixes for DateRangeInput

* Fix test

* Fix blur interactions

* Close the popover on Shift + TAB

* Format the date string on Enter in DateInput
cmslewis added a commit that referenced this pull request Dec 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants