Skip to content

fix(datetime-button): fix initial text not obeying datetime constraints#31218

Open
droc101 wants to merge 1 commit into
ionic-team:mainfrom
droc101:main
Open

fix(datetime-button): fix initial text not obeying datetime constraints#31218
droc101 wants to merge 1 commit into
ionic-team:mainfrom
droc101:main

Conversation

@droc101

@droc101 droc101 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Issue number: resolves #30183


What is the current behavior?

an IonDatetimeButton's default value (such as when .value is undefined) always uses the exact current date & time, regardless of any restrictions requested by the associated IonDatetime (such as only allowing 5 minute increments)

What is the new behavior?

  • The default display value of an IonDatetimeButton now follows the constraints on its associated IonDatetime
  • The actual default .value of the IonDatetimeButton is unchanged
  • A new public method async getClosestDate(date: Date) => Promise<Date> has been added to IonDatetime to facilitate this change. If this should not be a public method, I can work on changing that.
  • A new private method getClosestDatetimeParts(parts: DatetimeParts) => DatetimeParts has been added to IonDatetime as a helper to the previously mentioned getClosestDate method, and to deduplicate code.

Does this introduce a breaking change?

  • Yes
  • No

…aints

expose new `getClosestDate(date: Date) => Promise<Date>` function in the Datetime class and use it in DatetimeButton to round the current time (default value) into a date that matches the constraints provided on the Datetime element (dayValues, minuteValues, etc.)

closes ionic-team#30183
@droc101 droc101 requested a review from a team as a code owner June 15, 2026 22:04
@droc101 droc101 requested a review from BenOsodrac June 15, 2026 22:04
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

@droc101 is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added package: core @ionic/core package package: angular @ionic/angular package labels Jun 15, 2026
@vercel

vercel Bot commented Jun 15, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
ionic-framework Ready Ready Preview, Comment Jun 15, 2026 11:13pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: angular @ionic/angular package package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: ion-datetime-button does not respect minuteValues and others

1 participant