Skip to content

fix(datetime): scroll failing for adjacent days on ios#31033

Merged
os-davidlourenco merged 2 commits intomainfrom
ROU-12668
Mar 25, 2026
Merged

fix(datetime): scroll failing for adjacent days on ios#31033
os-davidlourenco merged 2 commits intomainfrom
ROU-12668

Conversation

@os-davidlourenco
Copy link
Copy Markdown
Contributor

@os-davidlourenco os-davidlourenco commented Mar 24, 2026

Issue number: resolves internal


What is the current behavior?

When the user swipes to a previous month that has adjacent days and selects one of the adjacent days from a previous month, the datetime selects the day but fails to scroll to the previous month.

What is the new behavior?

When a user clicks on a previous adjacent day after swiping the month, the calendar scrolls to the previous month. The same is applied to the next month.

Does this introduce a breaking change?

  • Yes
  • No

Other information

The previous behavior was only reproducible on iOS real devices.

@os-davidlourenco os-davidlourenco requested a review from a team as a code owner March 24, 2026 15:58
@os-davidlourenco os-davidlourenco added package: core @ionic/core package type: bug a confirmed bug report labels Mar 24, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ionic-framework Ready Ready Preview, Comment Mar 25, 2026 3:07pm

Request Review

Copy link
Copy Markdown
Member

@ShaneK ShaneK left a comment

Choose a reason for hiding this comment

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

A good start, but I think this might not be the best solution yet

left: 0,
behavior: 'smooth',
});
prevMonth.scrollIntoView({ behavior: 'smooth' });
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

scrollIntoView({ behavior: 'smooth' }) defaults to block: 'start', which scrolls ancestors vertically to align the element to the top of each scrollable viewport. The old scrollTo({ top: 0 }) was scoped to the calendar container. Adding block: 'nearest' would at least reduce the vertical scroll disturbance here. Also, the existing adjacent-days test only exercises the nextMonth() path (clicking a November adjacent day from October). Would it be possible to add a test that covers this fix directly? Something like: navigate back a month first, then click an adjacent day from the month before that, and assert the header title and ionChange value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To ensure this works in iOS, a calculation and approach similar to the next was developed in the previous. I also added a test to validate this behavior

Copy link
Copy Markdown
Member

@ShaneK ShaneK left a comment

Choose a reason for hiding this comment

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

This looks good to me! The only edge case I can think of that may remain is if you click on an adjacent day twice in a row, the second one before the swipe for the current one finishes settling. That feels like an unlikely edge case and may be out of scope for you to try fixing here, but just wanted to point it out in case you think otherwise

@os-davidlourenco os-davidlourenco added this pull request to the merge queue Mar 25, 2026
Merged via the queue into main with commit 3afd67f Mar 25, 2026
51 checks passed
@os-davidlourenco os-davidlourenco deleted the ROU-12668 branch March 25, 2026 18:38
os-davidlourenco added a commit that referenced this pull request Mar 26, 2026
Issue number: resolves internal

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

When the user swipes to a previous month that has adjacent days and
selects one of the adjacent days from a previous month, the datetime
selects the day but fails to scroll to the previous month.

When a user clicks on a previous adjacent day after swiping the month,
the calendar scrolls to the previous month. The same is applied to the
next month.

- [ ] Yes
- [x] No

<!--
  If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
  2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer
for more information.
-->

The previous behavior was only reproducible on iOS real devices.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package type: bug a confirmed bug report

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants