A common pattern in Ember is to dynamically add and remove templates as needed. Applying this pattern to the calcite-modal component exposes an issue where the slotted button elements visually disappear on subsequent re-renders.
| First render | Second render |
| - | - |
|
|
|
Slotted buttons continue to be visually present and clickable.
<button {{action 'openModal'}}>Open modal</button>
{{#if isOpen}}
<calcite-modal active>
<h3 slot="header">Title of the modal</h3>
<p slot="content">The actual content of the modal</p>
<calcite-button slot="primary">Primary</calcite-button>
</calcite-modal>
{{/if}}
<calcite-modal>
<h3 slot="header">Title of the modal</h3>
<p slot="content">The actual content of the modal</p>
<calcite-button slot="primary">Primary</calcite-button>
</calcite-modal>
<button {{action 'openModal'}}>Open modal</button>
{{#if isOpen}}
<calcite-modal active>
<h3 slot="header">Title of the modal</h3>
<p slot="content">The actual content of the modal</p>
<calcite-button slot="primary">Primary</calcite-button>
</calcite-modal>
{{/if}}
Observed in latest versions of Safari 14.1 and Chrome 90. Symptoms are similar to those observed in https://github.com/Esri/calcite-components/issues/1409. Possibly related to a similar underlying issue?
_Version_: @esri/[email protected]
@nwhittaker thank you for this really well documented bug report.
Thanks @caripizza. I added an alternative repro. case to the issue description. In summary, if another <calcite-modal> instance already exists in the DOM, the dynamically generated instance doesn't show the slotted buttons on its first render.
I've also noticed this behavior of the footer buttons disappearing. If you need another repro example, you can setup and run this project locally: https://github.com/Csmith246/calcite-4x-widget-sandbox
Installed.
@nwhittaker @Csmith246 Could you help verify this one? Thanks!
Looks good to me in the jsbin -- thanks for swift fix!
Most helpful comment
Thanks @caripizza. I added an alternative repro. case to the issue description. In summary, if another
<calcite-modal>instance already exists in the DOM, the dynamically generated instance doesn't show the slotted buttons on its first render.