Skip to content

feat(datepicker): set up input for date range picker #18159

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

Merged
merged 1 commit into from
Jan 17, 2020

Conversation

crisbeto
Copy link
Member

Sets up the UI and most of the boilerplate that we'll need for the input that is associated with a date range picker. Doesn't include any interactions with the datepicker itself yet.

Example of how it works:
demo

@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent pr: merge safe labels Jan 12, 2020
@crisbeto crisbeto requested a review from mmalerba as a code owner January 12, 2020 14:48
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jan 12, 2020
@crisbeto crisbeto force-pushed the date-selection-model-new branch 2 times, most recently from e3fd3e1 to ab5ff5a Compare January 12, 2020 15:26
@mmalerba
Copy link
Contributor

Can you send this PR to the date-range branch I just created instead? I'd like to keep it separate, because this part is more of a new feature, whereas the stuff currently on date-selection-model-new is a refactoring. If we keep it separate, we can work on getting the refactoring merged while the feature is in development.

@crisbeto
Copy link
Member Author

I'm not sure whether I'd be able to continue working on separately from here on out. The rest of the UI all depends on the date selection model being in place. Maybe now is the time to try and get the selection model merged in?

@mmalerba
Copy link
Contributor

Yeah I created that branch at the same commit as this one. You can work on that branch while we try to get this one in master

@crisbeto crisbeto changed the base branch from date-selection-model-new to date-range January 13, 2020 06:45
@crisbeto
Copy link
Member Author

Cool, I've changed the PR to point to the date-range branch.

@ccjmne
Copy link
Contributor

ccjmne commented Jan 13, 2020

This is fantastic and looks exactly like what I imagined. Thank you very much!

I have two remarks, however:

  1. The dash used to denote ranges should be the "en-dash" (), and I see we are using the "em-dash" here by default. I realise it merely is the default value for the @Input parameter, but I reckon we might as well use the more correct option!

  2. From the GIF you posted, it looks as if the behaviour of this form-field is a little different from that of the simpler ones, where having both a label and a placeholder text only shows the label so long as the field isn't focused nor valued (assuming floatLabel other than "always" — which seems to be the case).
    For reference, the field that uses a custom input control (last item in the form-field examples) does float the label "back and forth" as you focus in and blur out of either of the three backing inputs.

Maybe I'm overlooking some things though, I haven't even run the code and am just doing my daily quick scan of what's happening 🙂.

@mmalerba
Copy link
Contributor

I agree with @ccjmne that we should not force the label to always float, we can just hide the placeholders and dash when the label isn't floating

@crisbeto crisbeto force-pushed the date-selection-model-new branch from ab5ff5a to bb0f60a Compare January 13, 2020 20:38
@crisbeto
Copy link
Member Author

@mmalerba all of the feedback should be addressed, aside from the question about what the public API should look like.

}
}

// We want the start input to be flush against the separator, no matter how much text it has, but
Copy link
Member

Choose a reason for hiding this comment

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

Why does the input need to be flush against the separator?

Looking at the gif of your demo, I think it would be better if the separate and end-date input didn't shift as you were typing into the start date. Would it be better to give the input a min-width (equivalent to e.g. "77/77/7777") so that the end date input doesn't shift as the user is typing?

Copy link
Member Author

@crisbeto crisbeto Jan 13, 2020

Choose a reason for hiding this comment

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

Because it looks weird if you typed something shorter and then the space around the separator was uneven, e.g.

11/11     - 12/12

Copy link
Member

Choose a reason for hiding this comment

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

What if we right-align the the input?

Copy link
Member Author

Choose a reason for hiding this comment

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

Which one? The start date input or the date range input in general? I think we'd just the same problem but in a different place.

Copy link
Member

Choose a reason for hiding this comment

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

I pulled down the PR and tried tweaking a few things locally. I concluded that everything I suggested looks worse than what you ultimately did. I have one more idea, though, which is to hide the end-date input placeholder once you start typing into the start-date input. I tried this out locally and I think it eliminates the appearance of the input getting pushed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please leave TODO's for anything that you will handle in a follow-up PR. I feel we've been getting a little lax with the "will handle in a follow-up PR" lately, and I'm worried that things might slip off our radar and never actually get done

Copy link
Member Author

Choose a reason for hiding this comment

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

I ended up just doing it now. Can you take one more look @mmalerba? The way it behaves now is that it hides the placeholders when one of these criteria is true:

  • The inputs are empty and they have focus.
  • The start input is focused and the end input is empty.

Copy link
Contributor

Choose a reason for hiding this comment

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

The way I was imagining it, the dash doesn't disappear. @jelbourn should take a look too, since he felt more strongly about the placeholder stuff

Copy link
Member Author

Choose a reason for hiding this comment

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

The way I was reading it the dash should disappear, otherwise you'll see it jump to the beginning when you start typing.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated it to keep the separator visible while the start has a value.

@crisbeto crisbeto force-pushed the date-selection-model-new branch from bb0f60a to cc66e6f Compare January 13, 2020 21:36
}
}

// We want the start input to be flush against the separator, no matter how much text it has, but
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also think about the edge cases related to this. e.g. what happens if I skip the start and type in the end input?

If we want to go with Jeremy's suggestion my mental model would be to treat them as a single placeholder, i.e. whenever one of the inputs has text in it both placeholders are hidden

@crisbeto crisbeto force-pushed the date-selection-model-new branch from cc66e6f to 73d4695 Compare January 15, 2020 21:34
@crisbeto
Copy link
Member Author

@mmalerba @jelbourn I've reworked it to use two projected inputs. Can you take another look?

@crisbeto crisbeto force-pushed the date-selection-model-new branch from 73d4695 to 6445c36 Compare January 15, 2020 21:39
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

Overall looks good, just a few more minor comments

}
}

// We want the start input to be flush against the separator, no matter how much text it has, but
Copy link
Member

Choose a reason for hiding this comment

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

Agreed that we should treat them conceptually as one placeholder. Do you want to do that in this PR or in a follow-up?

@crisbeto crisbeto force-pushed the date-selection-model-new branch from 6445c36 to 781a535 Compare January 16, 2020 07:14
@crisbeto
Copy link
Member Author

Addressed the latest set of feedback. Also fixed that the error state wasn't being calculated correctly.

@crisbeto crisbeto force-pushed the date-selection-model-new branch 2 times, most recently from a0c6c2e to 60aa620 Compare January 17, 2020 19:02
@crisbeto crisbeto force-pushed the date-selection-model-new branch 2 times, most recently from d371811 to 8444614 Compare January 17, 2020 21:11
Sets up the UI and most of the boilerplate that we'll need for the input that is associated with a date range picker. Doesn't include any interactions with the datepicker itself yet.
@crisbeto crisbeto force-pushed the date-selection-model-new branch from 8444614 to 5780d04 Compare January 17, 2020 21:17
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Jan 17, 2020
@jelbourn jelbourn merged commit 5ee2173 into angular:date-range Jan 17, 2020
@crisbeto crisbeto deleted the date-selection-model-new branch January 18, 2020 13:54
crisbeto added a commit that referenced this pull request Jan 24, 2020
Sets up the UI and most of the boilerplate that we'll need for the input that is associated with a date range picker. Doesn't include any interactions with the datepicker itself yet.
crisbeto added a commit to crisbeto/material2 that referenced this pull request Jan 24, 2020
Sets up the UI and most of the boilerplate that we'll need for the input that is associated with a date range picker. Doesn't include any interactions with the datepicker itself yet.
crisbeto added a commit that referenced this pull request Jan 29, 2020
Sets up the UI and most of the boilerplate that we'll need for the input that is associated with a date range picker. Doesn't include any interactions with the datepicker itself yet.
crisbeto added a commit that referenced this pull request Feb 5, 2020
Sets up the UI and most of the boilerplate that we'll need for the input that is associated with a date range picker. Doesn't include any interactions with the datepicker itself yet.
crisbeto added a commit that referenced this pull request Feb 17, 2020
Sets up the UI and most of the boilerplate that we'll need for the input that is associated with a date range picker. Doesn't include any interactions with the datepicker itself yet.
crisbeto added a commit to crisbeto/material2 that referenced this pull request Feb 17, 2020
Sets up the UI and most of the boilerplate that we'll need for the input that is associated with a date range picker. Doesn't include any interactions with the datepicker itself yet.
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants