Repository navigation
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v7.x
Current Behavior
I have a reusable date navigation component which holds ion-datetime-button, which also has, a back and forward buttons in order to navigate through time, and this component is used in two different pages, tab1 and tab2 in the headers, additionally, the ion-datetime has as presentation attribute as month-year. So in order to correctly make the navigation work on each page, I need to provide a unique id to my reusable component, if I do that, the presenation is not respected just because I am providing an id from outside.
presenation output I got, default

Am I not supposed to wrap Ionic components with my own?
**repository : https://github.com/Asac2142/ionic-date-navigation-demo **
**stackblitz : https://stackblitz.com/edit/angular-qw87gp?file=src%2Fapp%2Fexample2.component.html,src%2Fapp%2Fapp.component.html,src%2Fapp%2Fexample2.component.ts,src%2Fapp%2Fapp.module.ts **
Expected Behavior
If I provide an id to ion datetime, which uses ion datetime button, the presentation attribute should be respected
Steps to Reproduce
git clone https://github.com/Asac2142/ionic-date-navigation-demo.git
cd demoionic
npm i
ionic serve
Code Reproduction URL
Ionic Info
[WARN] Error loading @capacitor/ios package.json: Error: Cannot find module '@capacitor/ios/package.json'
Require stack:
- /usr/local/lib/node_modules/@ionic/cli/lib/project/index.js
- /usr/local/lib/node_modules/@ionic/cli/lib/index.js
- /usr/local/lib/node_modules/@ionic/cli/index.js
- /usr/local/lib/node_modules/@ionic/cli/bin/ionic
[WARN] Error loading @capacitor/android package.json: Error: Cannot find module '@capacitor/android/package.json'
Require stack:
- /usr/local/lib/node_modules/@ionic/cli/lib/project/index.js
- /usr/local/lib/node_modules/@ionic/cli/lib/index.js
- /usr/local/lib/node_modules/@ionic/cli/index.js
- /usr/local/lib/node_modules/@ionic/cli/bin/ionic
Ionic:
Ionic CLI : 7.1.1 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 7.0.5
@angular-devkit/build-angular : 15.2.8
@angular-devkit/schematics : 15.2.8
@angular/cli : 15.2.8
@ionic/angular-toolkit : 9.0.0
Capacitor:
Capacitor CLI : 5.0.2
@capacitor/android : not installed
@capacitor/core : 5.0.2
@capacitor/ios : not installed
Utility:
cordova-res : not installed globally
native-run : 1.7.2
System:
NodeJS : v18.13.0 (/usr/local/bin/node)
npm : 9.6.6
OS : Linux 5.15
Additional Information
No response

Activity
[-]bug: Providing a unique id to ion datetime button doesn't respect presentation attribute[/-][+]bug: datetime button does not update when datetime presentation changes[/+]liamdebeasi commentedon May 11, 2023
Thanks for the report. This is not a bug in Ionic, but I think we could have better error logging surrounding this.
The problem is that you are assigning
id="foo1"toapp-date-navigation. I understand this is input to theapp-date-navigationcomponent that you then pass toion-datetime, but this is also being set as the ID on theapp-date-navigationelement in the DOM. As a result, you have two elements withid="foo1":app-date-navigationandion-datetime. Whenion-datetime-buttonqueries for#foo1, it getsapp-date-navigationnotion-datetime. Changing theidinput onapp-date-navigationto not collide with the global ID attribute will fix the issue.I am going to close this as this is not a bug in Ionic, but I'll look into adding a error when
ion-datetime-buttonreceives a non-datetime element.liamdebeasi commentedon May 11, 2023
Created a PR to add more logging for this scenario: #27456
fix(datetime-button): log error if non-datetime instance is passed (#…
ionitron-bot commentedon Jun 10, 2023
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.