Skip to content

Commit

Permalink
fix: components losing props
Browse files Browse the repository at this point in the history
Apply a fix, but the bug is due to: sveltejs/svelte#9177
  • Loading branch information
BearToCode committed Feb 16, 2024
1 parent b6954a4 commit 8c06fd2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 7 additions & 4 deletions packages/core/src/lib/components/layout/SidePanel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@
style="height: {linesHeights[lineIndex]}px;"
class="msm__line-number {component.type}"
>
{#if lineIndex == 0 && !disableMerging && component.sideAction}
{#if lineIndex == 0 && !disableMerging && component.sideAction && dispatch !== undefined}
<svelte:component
this={component.sideAction.component}
{...component.sideAction.props}
{component}
{dispatch}
{...{ ...component.sideAction.props, dispatch, component }}
/>
<!--
☝️ The weird spread is needed due to a Svelte bug affecting the use of
`<svelte:component>` with spread props and normal ones in v4.
See here for more details: https://github.com/sveltejs/svelte/issues/9177
-->
{/if}

<pre>{startingLineNumber + lineIndex}</pre>
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/lib/components/layout/View.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,13 @@
{#each sideComponents as blockComponent}
<svelte:component
this={blockComponent.component}
component={blockComponent}
{...blockComponent.props}
{...{ ...blockComponent.props, component: blockComponent }}
/>
<!--
☝️ The weird spread is needed due to a Svelte bug affecting the use of
`<svelte:component>` with spread props and normal ones in v4.
See here for more details: https://github.com/sveltejs/svelte/issues/9177
-->
{/each}
</div>

Expand Down

0 comments on commit 8c06fd2

Please sign in to comment.