Skip to content

bug: datetime button does not update when datetime presentation changes #27452

Closed as not planned

Description

@Asac2142

Prerequisites

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="month-year"
image

presenation output I got, default
image

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

https://github.com/Asac2142/ionic-date-navigation-demo

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

  1. changed the title [-]bug: Providing a unique id to ion datetime button doesn't respect presentation attribute[/-] [+]bug: datetime button does not update when datetime presentation changes[/+] on May 11, 2023
  2. added
    package: core
    type: bug
    on May 11, 2023
  3. removed
    package: core
    type: bug
    on May 11, 2023
  4. liamdebeasi commented on May 11, 2023

    @liamdebeasi
    Contributor

    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" to app-date-navigation. I understand this is input to the app-date-navigation component that you then pass to ion-datetime, but this is also being set as the ID on the app-date-navigation element in the DOM. As a result, you have two elements with id="foo1": app-date-navigation and ion-datetime. When ion-datetime-button queries for #foo1, it gets app-date-navigation not ion-datetime. Changing the id input on app-date-navigation to 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-button receives a non-datetime element.

  5. liamdebeasi commented on May 11, 2023

    @liamdebeasi
    Contributor

    Created a PR to add more logging for this scenario: #27456

  6. ionitron-bot commented on Jun 10, 2023

    @ionitron-bot

    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.

  7. locked and limited conversation to collaborators on Jun 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions