Skip to content

Conversation

@brandyscarney
Copy link
Member

@brandyscarney brandyscarney commented Nov 5, 2025

Issue number: N/A


What is the current behavior?

The Datetime component breaks CSP rules due to the following:

  1. Datetime is using ion-buttons which uses scoped encapsulation.
  2. When using the ionic theme, it imports Phosphor icons as data URIs, which are blocked by connect-src 'self' blob:.

What is the new behavior?

  • Remove all usages of ion-buttons, removing the dependency on a scoped component
  • Updates the styling to account for the removal of ion-buttons
  • Updates ion-button to change its styles based on being inside of an ion-datetime

Phosphor icons have not been removed because there is a workaround for it and we will remove its usage across all components in future work.

Does this introduce a breaking change?

  • Yes
  • No

This shouldn't cause breaking changes but because we are no longer recommending users use ion-buttons with custom buttons I am marking it as a breaking change.

BREAKING CHANGE:

- The `ion-buttons` component has been removed from the internal implementation of `ion-datetime` and is no longer required when passing custom buttons to the `slot="buttons"`. When providing custom buttons, use a `div` element instead of `ion-buttons`. While existing code using `ion-buttons` may continue to work visually, future updates to the `ion-buttons` component may cause any styles you rely on to break.

@vercel
Copy link

vercel bot commented Nov 5, 2025

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

Project Deployment Review Updated (UTC)
ionic-framework Ready Ready Preview, Comment Jan 16, 2026 9:34pm

Request Review

@github-actions github-actions bot added the package: core @ionic/core package label Nov 5, 2025
@brandyscarney brandyscarney changed the title refactor(datetime): remove usage of ion-buttons and Phosphor icons refactor(datetime): remove usage of ion-buttons Dec 17, 2025
Copy link
Member Author

Choose a reason for hiding this comment

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

This test was renamed to custom-clear-button

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 before behavior for 1 custom button in the ionic theme was to align it to the left, however, I think this is more desired since when showing only the clear button by default it aligns center:

<ion-datetime value="2020-03-14" show-clear-button="true"></ion-datetime>
Image

Copy link
Member Author

Choose a reason for hiding this comment

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

This test is new - we were not previously capturing how it looks when passing more than 1 custom button.

Copy link
Member Author

Choose a reason for hiding this comment

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

This test is new - we were not previously capturing how it looks when passing more than 1 custom button. You can compare how this looks to the docs example: https://ionicframework.com/docs/api/datetime#customizing-button-elements

Copy link
Member Author

Choose a reason for hiding this comment

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

I renamed the existing test for custom buttons (one button passed) and then added 2 more tests showing how it looks when you pass 2 or 3 buttons to make sure the behavior was the same as before.

@brandyscarney brandyscarney changed the title refactor(datetime): remove usage of ion-buttons fix(datetime): remove ion-buttons to fix CSP violations Dec 18, 2025
Copy link
Member Author

Choose a reason for hiding this comment

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

I compared this test locally with what's on next and saw no differences so I think this might just be Playwright: https://ionic-framework-git-next-ionic1.vercel.app/src/components/datetime/test/custom

@brandyscarney brandyscarney marked this pull request as ready for review December 18, 2025 22:49
@brandyscarney brandyscarney requested a review from a team as a code owner December 18, 2025 22:49
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have a ticket to look into fixing the "Invalid Time"?

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't look like it but that is how every screenshot in this folder looks and not related to my PR: https://github.com/ionic-team/ionic-framework/tree/main/core/src/components/datetime/test/basic/datetime.e2e.ts-snapshots

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

Development

Successfully merging this pull request may close these issues.

4 participants