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

fix: DateRange - startdate flicker to epoch0, auto enddate decrease and larger range selection #1893

Open
wants to merge 4 commits into
base: next
Choose a base branch
from

Conversation

AyushAgrawal-A2
Copy link
Contributor

@AyushAgrawal-A2 AyushAgrawal-A2 commented Apr 15, 2024

Description

closes #1875
closes #1892

Problems Identified:

  • Infinite reactive call - query depends on data which depends on $input[name].(start & end) which depends on startString & endString which depends back on query . $query is required to be run once to get date range for available data, but here it is getting triggered repeatedly due to reactive dependencies. When $query was being refetched startString null coalesce to epoch0 and endString null coalesce to todays date.
  • selectedDateRange changes $input[name].(start & end) which changes startString & endString due to above mentioned infinite call. This disables dates outside current selection.
  • dateToYYYYMMDD function used Date.toISOString() method, which has date in UTC format. This results in previous date for some locale. This combined with infinite call bug, was repeatedly decrementing end date.

Checklist

  • For UI or styling changes, I have added a screenshot or gif showing before & after
  • I have added a changeset
  • I have added to the docs where applicable
  • I have added to the VS Code extension where applicable

Copy link

changeset-bot bot commented Apr 15, 2024

🦋 Changeset detected

Latest commit: 9ba8e2b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@evidence-dev/core-components Patch
@evidence-dev/evidence Patch
my-evidence-project Patch
@evidence-dev/components Patch
evidence-test-environment Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Apr 15, 2024

Deploy Preview for evidence-development-workspace ready!

Name Link
🔨 Latest commit 9ba8e2b
🔍 Latest deploy log https://app.netlify.com/sites/evidence-development-workspace/deploys/662173599d78fb00096cbf8c
😎 Deploy Preview https://deploy-preview-1893--evidence-development-workspace.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Apr 15, 2024

Deploy Preview for next-docs-evidence ready!

Name Link
🔨 Latest commit 9ba8e2b
🔍 Latest deploy log https://app.netlify.com/sites/next-docs-evidence/deploys/6621735954bf3f00073b8b57
😎 Deploy Preview https://deploy-preview-1893--next-docs-evidence.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@archiewood
Copy link
Member

Can you add a test case to the example-project to show this working?

@AyushAgrawal-A2
Copy link
Contributor Author

@archiewood
I have added test case to example-project at /input-components/date-range/

Date Error (solved by modifying dateToYYYYMMDD fn)
image

Infinite reactive call & limited date range error - (Screencast after solving date error)
before.webm

After:
after.webm

Copy link
Member

@ItsMeBrianD ItsMeBrianD left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @AyushAgrawal-A2!

A couple notes here and one requested change (template string needs to be made easier to read)

Comment on lines +93 to +94
start: selectedDateRange.start?.toString() ?? dateToYYYYMMDD(new Date(0)),
end: selectedDateRange.end?.toString() ?? dateToYYYYMMDD(new Date())
Copy link
Member

Choose a reason for hiding this comment

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

Does this change cause a loss of timezone information?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ItsMeBrianD
Actually 'selectedDateRange' object has start and end fields, both of which are CalenderDate objects.
As the user is directly selecting a date, timezone is not required. We need just the selected date. Converting to Date object can lead to internationalization issues. This is recommended in their docs:
https://react-spectrum.adobe.com/internationalized/date/CalendarDate.html#conversion
image

Luckily the toString method give the date string directly in required format. We can just skip the conversion to Date object and then to string in dateToYYYYMMDD fn.

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