Skip to content

Proposal: Don't show date format in range header text if no date is selected #11

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

Closed
kfirba opened this issue Sep 11, 2019 · 1 comment
Closed
Labels
Feature New feature or request
Milestone

Comments

@kfirba
Copy link
Contributor

kfirba commented Sep 11, 2019

Hey!

Currently, the header text is showing something like From DD MM YYYY and To DD MM YYYY as the placeholder when there is no date selected, which is kind of weird in my opinion. Users are usually not aware of date formats and it does not give them any real benefit.

I propose 2 solutions:

  1. Don't show the placeholder at all. Just like you'd done in the "single date" mode, show a - before the user chooses a date.
  2. Just show the From and To texts without the date format.

Personally, I lean toward the second option as it gives the user some indication that this is a range picker and we are "waiting" for his input, opposed to the - solution where it's not immediately clear what it stands for.

The change should be rather easy, for the second solution:

export function getRangeDatesFormatted ({ start, end } = {}, { lang }, format) {
  const locale = getLocale(lang);

  if (!start && !end) {
    return ` ~ `;
  }

  if (!start && end) {
    return ` ~ ${dayjs(end).locale(locale).startOf('day').format(format)}`;
  }

  if (start && !end) {
    return `${dayjs(start).locale(locale).startOf('day').format(format)} ~ `;
  }

  return `\
${dayjs(start).locale(locale).startOf('day').format(format)} \
~ \
${dayjs(end).locale(locale).startOf('day').format(format)}`;
}
@mathieustan mathieustan added Feature New feature or request v0.1.8 labels Sep 12, 2019
@mathieustan mathieustan added this to the v0.1.8 milestone Sep 12, 2019
@mathieustan
Copy link
Owner

Done in V0.1.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants