1
0
Fork 0
mirror of synced 2024-09-08 13:41:09 +12:00

Fix crash when deleting a selected side panel component

This commit is contained in:
Andrew Kingston 2022-11-23 12:33:31 +00:00
parent 8ed2227280
commit a04f58dd23

View file

@ -28,40 +28,32 @@
$: open = $sidePanelStore.contentId === $component.id
const showInSidePanel = (el, visible) => {
const target = document.getElementById("side-panel-container")
const node = el.parentNode
const destroy = () => {
if (target.contains(node)) {
target.removeChild(node)
}
}
const update = visible => {
const target = document.getElementById("side-panel-container")
const node = el
if (visible) {
if (!target.contains(node)) {
target.appendChild(node)
}
el.hidden = false
} else {
destroy()
el.hidden = true
if (target.contains(node)) {
target.removeChild(node)
}
}
}
// Apply initial visibility
update(visible)
return {
update,
destroy,
}
return { update }
}
</script>
<div
use:styleable={$component.styles}
use:showInSidePanel={open}
hidden
class="side-panel"
class:open
>
<slot />
</div>
@ -69,12 +61,15 @@
<style>
.side-panel {
flex: 1 1 auto;
display: flex;
display: none;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
gap: var(--spacing-xl);
}
.side-panel.open {
display: flex;
}
.side-panel :global(.component > *) {
max-width: 100%;
}