-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to Svelte 4 #3543
Upgrade to Svelte 4 #3543
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good mostly, just a few concerns.
@@ -68,7 +68,7 @@ | |||
|
|||
<div> | |||
{#if showForm} | |||
<div class="mt-6 mb-4 flex flex-col gap-y-4" transition:slide> | |||
<div class="mt-6 mb-4 flex flex-col gap-y-4" transition:slide|global> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have seen issues with global transitions. Has it been fixed in svelte4? Applies to all places where this change has been made.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Svelte 4, transitions are local by default. In Svelte 3, they were global by default. So this code ensures our application behaves the same as it did with Svelte 3.
All the changes to transitions were made automatically when I ran the Svelte 4 migration script: npx svelte-migrate@latest svelte-4
.
I agree we should be wary of global transitions, but let's consider application behavior changes in a separate PR.
@@ -77,7 +77,7 @@ are details left to the consumer of the component; this component should remain | |||
{active} | |||
/> | |||
</Chip> | |||
<div slot="tooltip-content" transition:fly|local={{ duration: 100, y: 4 }}> | |||
<div slot="tooltip-content" transition:fly={{ duration: 100, y: 4 }}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|local
was added to fix issues with elements lingering. Has it been fixed in svelte 4? Applies to all instances of this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above – transitions are now local by default
@@ -93,6 +93,7 @@ are details left to the consumer of the component; this component should remain | |||
<RemovableListMenu | |||
{excludeStore} | |||
slot="floating-element" | |||
let:toggleFloatingElement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the migration guide's section on default slot bindings.
Previously, we were using default slot props (like toggleFloatingElement
) in named slots (like slot="floating-element"
). But that's no longer allowed. Now, to migrate, I've added a named slot prop toggleFloatingElement
.
@@ -41,6 +41,7 @@ and the menu closes. | |||
<slot {handleClose} toggleMenu={toggleFloatingElement} {active} /> | |||
<Menu | |||
slot="floating-element" | |||
let:handleClose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Wont it mask the variable defined above on WithTogglableFloatingElement
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same answer as above – named slots no longer have access to the default slot props
Closes #2684
This PR upgrades Svelte 3 to Svelte 4. A handful of changes were required:
web
workspacesweb
dependencies to versions that support Svelte 4@rgossiaux/svelte-headlessui
has not yet added official support for Svelte 4. Given community members have reported that the package does work with Svelte 4 in practice, I've included an npm override in the rootpackage.json
.floating-element
changes)derived()
store function no longer accepts falsy values (see thetimeseries-data-store
refactor)@bufbuild/protobuf
's base64 functions.onMount
not getting called byvitest
. Fixed by following this StackOverflow post.