-
-
Notifications
You must be signed in to change notification settings - Fork 832
Closed
ionic-team/ionic-framework
#25838Labels
Bug: ValidatedThis PR or Issue is verified to be a bug within StencilThis PR or Issue is verified to be a bug within Stencil
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.
Stencil Version
2.13.0
Current Behavior
In the Ionic Framework, on the display test of ion-datetime, changing the presentation prop of the datetime component sometimes causes the ref in renderCalendarBody to fire twice and/or get set to null. (See steps to repro for details)
Expected Behavior
The ref should not be set to null, because the element in question is present in the DOM.
Steps to Reproduce
- Clone the
ionic-frameworkrepo. - Open
core/src/components/datetime/datetime.tsx. In therenderCalendarBodyfunction, add aconsole.logto therefcallback like so:<div class="calendar-body ion-focusable" ref={el => { console.log('ref:', el); this.calendarBodyRef = el} } tabindex="0"> - Run
npm run startin the/coredirectory. Once the build is finished, go here in your browser: http://localhost:3333/src/components/datetime/test/display - Change the "presentation" dropdown to "time-date." Note in the console that the
refcallback fires twice, receivingnullfirst, then the proper element. - Change the "presentation" back to "date-time." Note that the callback fires twice again, but in the opposite order, such that
this.calendarBodyReffinishes atnull.
Code Reproduction URL
http://localhost:3333/src/components/datetime/test/display
Additional Information
- The source for the
displaytest can be found at/core/src/components/datetime/test/display/index.html. - Changing "presentation" to "date" only fires the
refonce. - Changing it to "time" sets the
refto null, which in this case is correct behavior, since there is no calendar body to render in this mode. renderCalendarBodyis called inrenderCalendar, which is called inrenderDatetime, which returns an array that gets passed directly to therenderfunction.- Both
date-timeandtime-datepresentations lead to the same render functions being called inrenderDatetime, just in a different order.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Bug: ValidatedThis PR or Issue is verified to be a bug within StencilThis PR or Issue is verified to be a bug within Stencil