Skip to content

fix(datetime): discard unconfirmed selection on cancel - #31558

Open
ShaneK wants to merge 1 commit into
mainfrom
FW-7061
Open

ShaneK wants to merge 1 commit into
mainfrom
FW-7061

Conversation

@ShaneK

@ShaneK ShaneK commented Oct 9, 2026

Copy link
Copy Markdown
Member

Issue number: resolves #30777, resolves #27975


What is the current behavior?

Currently, when ion-datetime is inside a modal or popover (usually through ion-datetime-button), cancelling or dismissing the overlay leaves the unconfirmed selection in place. The cancel() method only emits ionCancel and closes the overlay, so reopening the datetime shows the cancelled date as selected even though value never changed.

What is the new behavior?

The datetime now listens for its parent overlay's dismiss event and resets its selection to value unless the overlay was dismissed with the datetime-confirm role. That covers the Cancel button, backdrop taps, swipes and hardware back. The reset skips the month animation since the overlay has already animated out, otherwise cancelling a selection in another month left the calendar stuck on that month when reopened. Calling cancel() on an inline datetime now restores the committed selection right away.

Does this introduce a breaking change?

  • Yes
  • No

Other information

There was an earlier attempt at this in #27976 that called reset() from cancel(), which was closed until the design was settled. This reprocesses value directly instead, so it doesn't pick up the clearing behavior of reset().

This changes behavior in a few edge cases:

  • Calling cancel() without closing an overlay now resets the selection, where before it only emitted ionCancel.
  • If canDismiss blocks the dismiss, the selection stays, since the user is still in the picker.
  • Apps that dismiss with a custom role and then call confirm() from their own onDidDismiss handler will confirm the original value, because the datetime resets first. Calling confirm(true), or confirm() before dismissing, isn't affected.

Use the "Popover - Custom" and "Modal - Custom" examples, pick a date, cancel, then reopen:

@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
ionic-framework Ready Ready Preview Oct 9, 2026 12:52pm UTC

Request Review

@ShaneK
ShaneK requested a review from a team as a code owner October 9, 2026 12:52
@ShaneK
ShaneK requested a review from brandyscarney October 9, 2026 12:52
@github-actions github-actions Bot added the package: core @ionic/core package label Oct 9, 2026

@thetaPC thetaPC left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

This branch was successfully deployed

1 active deployment
Preview — e47f46f3 Deployed Oct 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

2 participants