Prerequisites
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-framework repo.
- Open
core/src/components/datetime/datetime.tsx. In the renderCalendarBody function, add a console.log to the ref callback like so: <div class="calendar-body ion-focusable" ref={el => { console.log('ref:', el); this.calendarBodyRef = el} } tabindex="0">
- Run
npm run start in the /core directory. 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
ref callback fires twice, receiving null first, 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.calendarBodyRef finishes at null.
Code Reproduction URL
http://localhost:3333/src/components/datetime/test/display
Additional Information
- The source for the
display test can be found at /core/src/components/datetime/test/display/index.html.
- Changing "presentation" to "date" only fires the
ref once.
- Changing it to "time" sets the
ref to null, which in this case is correct behavior, since there is no calendar body to render in this mode.
renderCalendarBody is called in renderCalendar, which is called in renderDatetime, which returns an array that gets passed directly to the render function.
- Both
date-time and time-date presentations lead to the same render functions being called in renderDatetime, just in a different order.
Prerequisites
Stencil Version
2.13.0
Current Behavior
In the Ionic Framework, on the
displaytest ofion-datetime, changing thepresentationprop of thedatetimecomponent sometimes causes therefinrenderCalendarBodyto fire twice and/or get set tonull. (See steps to repro for details)Expected Behavior
The
refshould not be set tonull, because the element in question is present in the DOM.Steps to Reproduce
ionic-frameworkrepo.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">npm run startin the/coredirectory. Once the build is finished, go here in your browser: http://localhost:3333/src/components/datetime/test/displayrefcallback fires twice, receivingnullfirst, then the proper element.this.calendarBodyReffinishes atnull.Code Reproduction URL
http://localhost:3333/src/components/datetime/test/display
Additional Information
displaytest can be found at/core/src/components/datetime/test/display/index.html.refonce.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.date-timeandtime-datepresentations lead to the same render functions being called inrenderDatetime, just in a different order.