svelte icon indicating copy to clipboard operation
svelte copied to clipboard

Svelte 5: default `intro` to `true` when using `mount`

Open Rich-Harris opened this issue 10 months ago • 2 comments

Describe the problem

Presently, we disable intro transitions when mounting components. The reason we do this is to avoid flashes when hydrating (we don't want to 'fade in' an element that's already visible), but that only really applies to hydrate.

Describe the proposed solution

Default intro to true when calling mount, and false when calling hydrate. Continue to respect the option if it is set explicitly (which only really applies to mount; it would be very unusual to enable intros when hydrating).

This would be a breaking change.

Importance

nice to have

Rich-Harris avatar Apr 21 '24 23:04 Rich-Harris

Has there been widespread confusion about the existing behavior? Couldn't this have been done this way in Svelte 3, too (due to the hydrate constructor option)? Trying to estimate what the majority wants here and if this switch of defaults is warranted.

dummdidumm avatar Apr 23 '24 09:04 dummdidumm

I don't know about widespread confusion — it's fairly well signposted in the docs. We absolutely could have done it in Svelte 3, we just overlooked it, and a new major is the right time to rectify a bad decision. It feels like an absolute no-brainer to me — as a component author you've already made your intent explicit by adding the transition: directive in the first place. I guess we could run a poll but we should be wary of creating poll fatigue by running them for every small decision

Rich-Harris avatar Apr 23 '24 13:04 Rich-Harris

Note: we should keep the existing behaviour when using createClassComponent and asClassComponent

Rich-Harris avatar Jun 05 '24 14:06 Rich-Harris