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

Date picker calendar grids: Previous and next month and year functions do not behave as documented #2581

Closed
smellai opened this issue Jan 11, 2023 · 5 comments
Assignees
Labels
enhancement Any addition or improvement that doesn't fix a code bug or prose inaccuracy Example Page Related to a page containing an example implementation of a pattern Feedback Issue raised by or for collecting input from people outside APG task force

Comments

@smellai
Copy link

smellai commented Jan 11, 2023

I found an edge case with 'PageUp' and 'PageDown' navigation.

  1. current day selected/focused: March 31
  2. press PageUp
  3. March 2 is selected because February 31 doesn't exist.

Proposed solution:

var newDate = new Date(
  date.getFullYear(),
  date.getMonth() - 1,
  Math.min(date.getDate(), lastDayOfNextMonth.getDate())
);

And similar for shift+PageUp:

var newDate = new Date(
  date.getFullYear() + 1,
  date.getMonth(),
  Math.min(date.getDate(), lastDayOfNextMonth.getDate())
);

That last one covers if current year has Feb 29 and next year obviously not.

@mcking65
Copy link
Contributor

Hi @smellai,

Thank you for the feedback. There are several possible solutions for what to do when the same date does not exist in the previous or next period of time. I believe the task force considered the approach you suggest. The approach that was chosen is documented in the keyboard table as follows:

Page Up:

  • Changes the grid of dates to the previous month.
  • Sets focus on the same day of the same week. If that day does not exist, then moves focus to the same day of the previous or next week.

Page Down:

  • Changes the grid of dates to the next month.
  • Sets focus on the same day of the same week. If that day does not exist, then moves focus to the same day of the previous or next week.

I recall the task force having discussion of the above design decision, but I can't find documentation of the discussion in any of the related issues. It may be in meeting minutes; that would be a more time consuming search. It may be more expedient to re-open the discussion.

If you think the task force should re-open this discussion, would you please:

  1. Provide your reasons for why the current behavior should be replaced with an alternative behavior,
  2. And, Define your proposed alternative behavior in prose the way it would be described in the keyboard table.

@smellai
Copy link
Author

smellai commented Jan 18, 2023

I could be ok with the approach described in the documentation, but doesn't look like the demo is working in the way described. This is what I see:

  • March 31 selected (Friday)
  • Page down
  • May 1 is selected (Monday)

and

  • March 31 selected (Friday)
  • Page up
  • March 3 selected (Friday)
    this could be correct according to specs (same day of next week selected), but we stay in the same month, looks a bit weird.

and

  • February 29, 2024 selected (Thursday)
  • Shift + Page up
  • March 1, 2024 selected (Wednesday)

@mani-rsg
Copy link

Hi @smellai and @mcking65 ,
I am facing the same issue as well. Reg the solution, I suggest using the 1st day of the month, if the focussed date of the previous month is not present in the navigated month. So by doing this it won't look weird for the below case as well.

  • March 31 selected (Friday)
  • Page up
  • March 3 selected (Friday)
    this could be correct according to specs (same day of next week selected), but we stay in the same month, looks a bit weird.

@mcking65 mcking65 added enhancement Any addition or improvement that doesn't fix a code bug or prose inaccuracy Example Page Related to a page containing an example implementation of a pattern Feedback Issue raised by or for collecting input from people outside APG task force labels Feb 7, 2023
@mcking65 mcking65 changed the title Date picker navigate through months and years issue Date picker calendar grids: Previous and next month and year functions do not behave as documented Apr 4, 2023
@mcking65
Copy link
Contributor

mcking65 commented Apr 4, 2023

We have decided to change the behavior so that previous/next month/year functions put focus on the last day of the month in the newly displayed month if the same day number does not exist. In this way, previous/next month will always move to a new month. Previous/next year are only affected if the focus is on Feb 29 when the function is activated.

This issue impacts both:

The changes in PR #2618 are on track to make it into production on April 11. It is possible that #2643 changes could make it at the same time, but if not, they will be on track to land before the end of April.

@mcking65 mcking65 added this to the H1/2023 Content Updates milestone Apr 4, 2023
mcking65 added a commit that referenced this issue Apr 4, 2023
… behavior for dates near end of month (pull #2618)

Provides partial resolution of #2581.
The remainder of the resolution is provided by #2643.

This PR changes behavior of commands for next and previous month and year In the combobox date picker when the currently focused date does not exist in the previous or next month or year. With these changes, if the same day number does not exist in the newly displayed month, the last day of the newly displayed month receives focus.

---------

Co-authored-by: Matt King <a11yThinker@gmail.com>
mcking65 added a commit that referenced this issue Jun 6, 2023
…nce with APG code style guide (pull #2643)

This PR complements PR #2618 to provide the remaining changes to resolve issue #2581.

This PR changes behavior of commands for next and previous month and year In the date picker dialog when the currently focused date does not exist in the previous or next month or year. With these changes, if the same day number does not exist in the newly displayed month, the last day of the newly displayed month receives focus.

In addition to the above enhancement, this PR also includes the following changes:
* Updates coding practices to use `class` constructor and pointer events
* Updates documentation of page up and page down commands
* Updates regression tests for page up and page down commands

---------

Co-authored-by: Matt King <a11yThinker@gmail.com>
@mcking65
Copy link
Contributor

mcking65 commented Jun 6, 2023

#2643 is now merged and will be in the next site publication, so closing this issue.

Thank you @smellai for raising this issue. It drove several improvements to the code and documentation.

Thank you @jongund for all the work on the PRs!

@mcking65 mcking65 closed this as completed Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Any addition or improvement that doesn't fix a code bug or prose inaccuracy Example Page Related to a page containing an example implementation of a pattern Feedback Issue raised by or for collecting input from people outside APG task force
Development

No branches or pull requests

4 participants