You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: <ion-datetime-button> not rendered inside modal #30504
I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v8.x
Current Behavior
When using <ion-datetime-button> inside a modal page (created via ModalController), the component does not render anything unless the linked <ion-datetime> and <ion-datetime-button> (e.g. with ID calendar-trigger) is already present in the DOM before the button is initialized.
This seems related to Web Component hydration timing in dynamically loaded views.
However, if a <ion-datetime> with the same ID is rendered earlier (inside a routed page) (even with display: none), the button suddenly works inside the modal, but is rendered from parent page without the possibility to use value binding from modal.
Expected Behavior
<ion-datetime-button> should correctly render and bind to its matching target, regardless of where in the component it appears, as long as the referenced element exists in the DOM at the time of rendering.
Hydration/timing should not cause the component to silently fail.
changed the title [-]bug: <ion-datetime-button> not rendered inside modal unless <ion-datetime> is pre-defined earlier in DOM[/-][+]bug: <ion-datetime-button> not rendered inside modal[/+]on Jun 30, 2025
I have the same problem, generally affecting all parts that somehow interfere with the DOM. This includes ion-datetime itself, but it is most noticeable with ion-datetime-button. What I also found out is that if the browser loads the data fast enough (which rarely happens), everything works fine, but if the data in the DOM is rendered more slowly, the problem occurs.
As you mentioned above, it is impossible to display this when activated via ID. Your fix works, but it is definitely not a solution for this to work. I noticed this problem since version 8.7.x.
EDIT: The problem occurs in many more places. It also happens to me with ion-icon, which I use wrapped in my own component (app-place-icon) and display inside a modal. The ion-icon is rendered, but the SVG inside is not rendered either. (when rendered in @for or other async method works perfectly) Tested on Angular 20. In order to draw it, I have to use a fix. It is also possible that this is only related to Angular, specifically the transition to Zoneless and Signals.
I can confirm this problem on multiple places in my app in conjunction with ion-datetime-button. The component is logging an error like ion-datetime-button No ion-datetime instance found for ID xxx.
This happens on Angular 20.1.5 and @ionic/angular 8.7.x. I'm not using Zoneless.
I have the same issue with ion-datetime-button. It doesn't show in ion-modal. I didn't find the solution to fix it. Solutions that render this component after entering it are also not working for me. So I just did it like that:
I left my templates as they were and instead created a patch that re-renders the icons after the first load in modals.
This is obviously just a workaround, but better than not having icons show up or migrating all my modal templates.
If there is a need for it, I can come back and share it here.
we have that on multiple places in modal with newest ionic version and angular 20. things like translated labels icon src fetched with a pipe etc. are not rendered. they are rendered as soon as if block is around the template.
edit: This only occurs when built and run on a phone, not when serving the app locally in the browser.
edit2: This does not seem to be a problem with inline modal, only when using modalController.create() it seems like
Instead of @defer on HTML i put @if with boolean signal on TS, then u use 'ionViewWillEnter' lifecycle ionic function and set the signal to true. Works like a charm
This is fixed in v8.8.12 by #31235. Modals opened with ModalController now render their template as soon as they're attached, so ion-datetime-button finds its ion-datetime. After updating, remove the @defer, @if and ionViewWillEnter workarounds from earlier comments, since ion-datetime-button looks up its ion-datetime only once and a deferred datetime can leave it empty.
Activity
[-]bug: <ion-datetime-button> not rendered inside modal unless <ion-datetime> is pre-defined earlier in DOM[/-][+]bug: <ion-datetime-button> not rendered inside modal[/+]jakubforman commentedon Aug 8, 2025
I have the same problem, generally affecting all parts that somehow interfere with the DOM. This includes
ion-datetimeitself, but it is most noticeable withion-datetime-button. What I also found out is that if the browser loads the data fast enough (which rarely happens), everything works fine, but if the data in the DOM is rendered more slowly, the problem occurs.As you mentioned above, it is impossible to display this when activated via ID. Your fix works, but it is definitely not a solution for this to work. I noticed this problem since version
8.7.x.Sometimes the fix didn't work, but this one did:
EDIT: The problem occurs in many more places. It also happens to me with
ion-icon, which I use wrapped in my own component (app-place-icon) and display inside a modal. Theion-iconis rendered, but the SVG inside is not rendered either. (when rendered in@foror other async method works perfectly) Tested on Angular 20. In order to draw it, I have to use a fix. It is also possible that this is only related to Angular, specifically the transition to Zoneless and Signals.without afterInit()
With afterInit() fix
@if (afterInit()) { <ion-icon class="category-icon" [color]="color" [name]="name"></ion-icon> }maatien commentedon Aug 12, 2025
I can confirm this problem on multiple places in my app in conjunction with
ion-datetime-button. The component is logging an error likeion-datetime-button No ion-datetime instance found for ID xxx.This happens on Angular 20.1.5 and @ionic/angular 8.7.x. I'm not using Zoneless.
k-scherbitsky commentedon Sep 9, 2025
I have the same issue with
ion-datetime-button. It doesn't show inion-modal. I didn't find the solution to fix it. Solutions that render this component after entering it are also not working for me. So I just did it like that:Instead of a popover, you can use a modal, but a popover looks better.
Environments:
HyperLife1119 commentedon Sep 10, 2025
I solved it by using @defer :/
troywweber7 commentedon Sep 30, 2025
@HyperLife1119 I had to use @defer on the
<ion-datetime-button>instead of on the<ion-datetime>.Eraldo commentedon Oct 4, 2025
I tried defer for all of my modal html and it still does not show the icons. 😢
troywweber7 commentedon Oct 4, 2025
It did seem like maybe the "@if" approach was more consistent than the "@defer" approach in working around the issue.
Eraldo commentedon Oct 4, 2025
I left my templates as they were and instead created a patch that re-renders the icons after the first load in modals.
This is obviously just a workaround, but better than not having icons show up or migrating all my modal templates.
If there is a need for it, I can come back and share it here.
Spinnenzunge commentedon Oct 20, 2025
we have that on multiple places in modal with newest ionic version and angular 20. things like translated labels icon src fetched with a pipe etc. are not rendered. they are rendered as soon as if block is around the template.
edit: This only occurs when built and run on a phone, not when serving the app locally in the browser.
edit2: This does not seem to be a problem with inline modal, only when using modalController.create() it seems like
hsochetra commentedon Oct 22, 2025
Using @defer around ion-datetime-button work!
lewisuzoma commentedon Apr 30, 2026
This still works. Thanks HyperLife1119
Varo95 commentedon May 21, 2026
Instead of @defer on HTML i put @if with boolean signal on TS, then u use 'ionViewWillEnter' lifecycle ionic function and set the signal to true. Works like a charm
@if(this.showPicker()){ <ion-datetime-button datetime="entry"></ion-datetime-button> } <ion-modal [keepContentsMounted]="true"> <ng-template> <ion-datetime #datetime id="entry" first-day-of-week="1" [(ngModel)]="this.date"> <ion-buttons slot="buttons"> <ion-button color="primary" (click)="datetime.cancel()">Cancel</ion-button> <ion-button color="primary" (click)="datetime.confirm()">Accept</ion-button> </ion-buttons> </ion-datetime> </ng-template> </ion-modal>Then on Ts file
thetaPC commentedon Nov 13, 2026
Thanks for the report, and sorry for the delay.
This is fixed in v8.8.12 by #31235. Modals opened with
ModalControllernow render their template as soon as they're attached, soion-datetime-buttonfinds itsion-datetime. After updating, remove the@defer,@ifandionViewWillEnterworkarounds from earlier comments, sinceion-datetime-buttonlooks up itsion-datetimeonly once and a deferred datetime can leave it empty.Closing this since it's fixed.