Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eager-experts-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: wait for commit promise instead of `settled`
12 changes: 8 additions & 4 deletions packages/kit/src/runtime/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,10 @@ async function navigate({

navigation_result.props.page.state = state;

/**
* @type {Promise<void> | undefined}
*/
let commit_promise;
if (started) {
const after_navigate = (
await Promise.all(
Expand Down Expand Up @@ -1722,7 +1726,7 @@ async function navigate({
const fork = load_cache_fork && (await load_cache_fork);

if (fork) {
void fork.commit();
commit_promise = fork.commit();
} else {
root.$set(navigation_result.props);
}
Expand All @@ -1738,9 +1742,9 @@ async function navigate({
const promises = [tick()];

// need to render the DOM before we can scroll to the rendered elements and do focus management
// svelte.settled is only available in Svelte 5
if (/** @type {any} */ (svelte).settled) {
promises.push(/** @type {any} */ (svelte).settled());
// so we wait for the commit if there's one
if (commit_promise) {
promises.push(commit_promise);
}
// we still need to await tick everytime because if there's no async work settled resolves immediately
await Promise.all(promises);
Expand Down
Loading