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: Fixes calendar jumping when switching months #3178

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pan-kot
Copy link
Member

@pan-kot pan-kot commented Jan 9, 2025

Description

The PR introduces placeholder dates to Calendar, Date picker, and Date range picker components such that each calendar always has exactly 6 rows of dates which ensures its size stays constant when user switches between months.

Rel: [llayAeObY9Ic], AWSUI-60266, #3140

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.43%. Comparing base (1f1d269) to head (0fc25bf).
Report is 30 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3178      +/-   ##
==========================================
+ Coverage   96.40%   96.43%   +0.02%     
==========================================
  Files         784      788       +4     
  Lines       22143    22256     +113     
  Branches     7594     7233     -361     
==========================================
+ Hits        21348    21463     +115     
+ Misses        788      786       -2     
  Partials        7        7              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pan-kot pan-kot force-pushed the fix-calendar-jumping branch from 084a386 to 3919c00 Compare January 9, 2025 19:21
@pan-kot pan-kot force-pushed the fix-calendar-jumping branch 2 times, most recently from 55f388c to 83d7c37 Compare January 10, 2025 18:43
@pan-kot pan-kot force-pushed the fix-calendar-jumping branch from dca0d08 to 82b9d62 Compare January 14, 2025 14:12
@pan-kot pan-kot force-pushed the fix-calendar-jumping branch from 82b9d62 to e1dc31c Compare January 14, 2025 15:11
@pan-kot pan-kot force-pushed the fix-calendar-jumping branch from 535f143 to 6a4dfb1 Compare January 20, 2025 14:59
@pan-kot pan-kot changed the title fix: (POC) Fixes calendar jumping when chaning month fix: Fixes calendar jumping when changing months Jan 23, 2025
@pan-kot pan-kot changed the title fix: Fixes calendar jumping when changing months fix: Fixes calendar jumping when switching months Jan 23, 2025
@@ -122,7 +123,7 @@ export class DrpDropdownWrapper extends ComponentWrapper {
): CalendarDateWrapper {
const gridClassName = grid === 'right' ? styles['second-grid'] : styles['first-grid'];
return this.findComponent(
`.${gridClassName} .${gridStyles.week}:nth-child(${row}) .${gridStyles.day}:nth-child(${column})`,
`.${gridClassName} .${testStyles['calendar-week']}[data-awsui-weekindex="${row}"] .${testStyles['calendar-date']}:nth-child(${column})`,
Copy link
Member Author

Choose a reason for hiding this comment

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

Using data- attribute instead of :nth-child() to exclude rows with placeholder dates only. That is necessary for the backward-compatibility, to ensure the indices of the monthly dates do not change.

@pan-kot pan-kot force-pushed the fix-calendar-jumping branch from 6a4dfb1 to 0fc25bf Compare January 23, 2025 09:52
isSelectionRight: boolean;
}

export class MonthCalendar {
Copy link
Member Author

Choose a reason for hiding this comment

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

The calendar abstraction helps calculating indices and styles for calendar grid, which is non-trivial due to presence of placeholder dates that are treated differently.

Ideally, the same abstraction should be reused between Calendar, and Date range picker components. However, those are currently using very different implementations and only one supports the year calendar. We can reuse the code between the components as soon we update those to use the same calendar element implementation.

@pan-kot pan-kot marked this pull request as ready for review January 26, 2025 06:49
@pan-kot pan-kot requested a review from a team as a code owner January 26, 2025 06:49
@pan-kot pan-kot requested review from connorlanigan and dpitcock and removed request for a team January 26, 2025 06:49
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.

1 participant