Fix side panel ejection

This commit is contained in:
Andrew Kingston 2022-12-07 09:51:47 +00:00
parent 608576ff3b
commit a846192494
1 changed files with 13 additions and 2 deletions

View File

@ -29,6 +29,17 @@
// Derive visibility
$: open = $sidePanelStore.contentId === $component.id
// Derive a render key which is only changed whenever this panel is made
// visible after being hidden. We need to key the content to avoid showing
// stale data when re-revealing a side panel that was closed, but we cannot
// hide the content altogether when hidden as this breaks ejection.
let renderKey = null
$: {
if (open) {
renderKey = Math.random()
}
}
const showInSidePanel = (el, visible) => {
const update = visible => {
const target = document.getElementById("side-panel-container")
@ -60,9 +71,9 @@
class="side-panel"
class:open
>
{#if open}
{#key renderKey}
<slot />
{/if}
{/key}
</div>
<style>