Skip to content

Conversation

taysea
Copy link
Collaborator

@taysea taysea commented Jun 30, 2022

What does this PR do?

Previously, Calendar could not handle Daylight Savings Time properly because it relied on ISOstring to infer timezone, however ISOstring only contains information related to UTC offset, but the actual timezone information is lost. See comment for more detail.

This PR refactors Calendar rely on Date object as opposed to ISO strings.

  • Calendar accepts ISOstrings as input --> normalizes the inputs as Date objects --> all logic is handled as Date objects --> only normalizes output supplied to onSelect as last step, returning dates as ISOstrings.
  • Additionally, to reduce complexity, consolidate logic, and improve control flow, this PR makes the following adjustments:
    • Internally, date and dates both feed an internal variable called value. API surface remains the same. All logic consider value to be either a Date object, an array of Date objects, a nested array of Date objects, or undefined.
  • Adds timezone test coverage to Jest scripts.

Where should the reviewer start?

What testing has been done on this PR?

How should this be manually tested?

Do Jest tests follow these best practices?

  • screen is used for querying.
  • The correct query is used. (Refer to this list of queries)
  • userEvent is used in place of fireEvent.
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

What are the relevant issues?

Closes #6043
Closes #6044

Screenshots (if appropriate)

Do the grommet docs need to be updated?

Should this PR be mentioned in the release notes?

Yes.

Is this change backwards compatible or is it a breaking change?

Backwards compatible + some bug fixes

@taysea taysea added bug issue that does not match design or documentation and requires code changes to address accessibility WCAG support and removed bug issue that does not match design or documentation and requires code changes to address accessibility WCAG support labels Jun 30, 2022
Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

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

It looks like I am no longer able to change the date on Calendars that don't have onSelect defined. (See Calendar/First on Sunday and Daylight Savings stories)

@taysea
Copy link
Collaborator Author

taysea commented Jul 14, 2022

It looks like I am no longer able to change the date on Calendars that don't have onSelect defined. (See Calendar/First on Sunday and Daylight Savings stories)

Good point -- the docs read that not specifying onSelect makes the component read only, so we are aligning to that: https://v2.grommet.io/calendar#onSelect

we should confirm, as a team, if that's the desired behavior.

@jcfilben
Copy link
Collaborator

jcfilben commented Jul 14, 2022

Good point -- the docs read that not specifying onSelect makes the component read only, so we are aligning to that: https://v2.grommet.io/calendar#onSelect

we should confirm, as a team, that that's desired behavior.

Ah okay that makes sense. I think that behavior is reasonable, we should just to be sure to call this out in the release notes since before we weren't enforcing this

@taysea taysea marked this pull request as ready for review July 15, 2022 00:09
Copy link
Contributor

@ericsoderberghp ericsoderberghp left a comment

Choose a reason for hiding this comment

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

nice cleanup

@taysea taysea requested a review from jcfilben July 19, 2022 00:06
Copy link
Collaborator

@jcfilben jcfilben 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!

Copy link
Collaborator

@MikeKingdom MikeKingdom 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. Thanks!

@ericsoderberghp ericsoderberghp merged commit 33d415c into grommet:master Jul 19, 2022
@taysea taysea deleted the Calendar-rework branch July 19, 2022 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DateInput daylight savings time Calendar daylight savings handling not working in certain timezones
5 participants