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

Updated calender-beta with better internal date management #960

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

MattCheely
Copy link
Collaborator

@MattCheely MattCheely commented Mar 4, 2025

This improves the calendar-beta component by migrating to a polyfill for the Temporal api. Temporal.PlainDate is much more suitable for working with calendar data than Date, removing quite a few corner cases.

This also includes API changes and other minor improvements.

It currently contains all of the original commits for the attempt at customizable dates, which I will rebase out after PR review.

  • Rebase and update commit message for changelog

Copy link

github-actions bot commented Mar 4, 2025

@daragh-king-genesys daragh-king-genesys force-pushed the feature/calendar-refactor branch from 6ec8ad4 to cddfbdb Compare March 4, 2025 13:10
/**
* The gux-day component is how we render a day within an calendar. It should
* not be used stand-alone.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typically we have nested child components in a components folder in the parent component.

// Set max value from the "max" input prop
if (this.slottedInput.max) {
this.maxValue = Temporal.PlainDate.from(this.slottedInput.max);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This might need to use a MutationObserver like disabled and required do on form fields.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is done - I took a bit of a different approach from the form fields that I think will be slightly more efficient. Let me know what you think.

break;
case 'ArrowRight':
event.preventDefault();
this.shiftFocusDate({ days: 1 });
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this should be linked to the step attribute on the input field.

Copy link
Collaborator Author

@MattCheely MattCheely Mar 6, 2025

Choose a reason for hiding this comment

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

How would that interact with the up and down arrows?

Edit: It looks like the native inputs disable anything that's not aligned with the step. That would require a pretty decent re-work of the date logic. I'm inclined to add a separate story to add step support rather than holding up this PR.

@MattCheely MattCheely force-pushed the feature/calendar-refactor branch from 549147b to 7132c71 Compare March 6, 2025 06:22
@MattCheely MattCheely force-pushed the feature/calendar-refactor branch from 62a3133 to 437f8d9 Compare March 6, 2025 07:23
@321gillian
Copy link
Collaborator

321gillian commented Mar 6, 2025

This is minor but if I click on the last date of the previous month, the calendar will show the previous month with the last date selected but the focus ring is on the last date of the month before. This is not present in current version.
Screenshot 2025-03-06 at 12 02 27

Screen.Recording.2025-03-06.at.12.19.43.mov

Same thing happens if I go forward

@321gillian
Copy link
Collaborator

321gillian commented Mar 6, 2025

Tabbing into the day area:

Also small thing and may be intentional. When tabbing in to the days, the first in the tab order is 6th on an empty date selection and always the number of the selected date when there's a selection. On the previous version, it was the first of the month.

Screen.Recording.2025-03-06.at.12.29.50.mov

Min Max Date:

Clicking on the dates outside the min and max shows a focus ring.

Screen.Recording.2025-03-06.at.12.57.43.mov

@MattCheely
Copy link
Collaborator Author

@321gillian The rogue focus rings should be gone now. The focused day behavior when tabbing is the result of two implementation details:

  • When no date is set, the default focus day is the current day (so right now it's the 18th for me)
  • Moving forward and back a month shifts the focus day a month ahead or back (e.g. from March 18 to April 18th)
    • this is the same for PageUp/Down as for the buttons at the top, but I could see an argument for them being different

@321gillian
Copy link
Collaborator

All focus ring stuff seems good to me now

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.

3 participants