Skip to content

Commit

Permalink
fix: Command.Root onStateChange not firing after first mount
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte committed Feb 11, 2025
1 parent 08566c8 commit 5a4ae20
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-cycles-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"bits-ui": patch
---

fix: `onStateChange` of `Command.Root` not firing after initial mount
4 changes: 2 additions & 2 deletions packages/bits-ui/src/lib/bits/command/command.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CommandRootState {
_commandState = $state<CommandState>(null!);

#snapshot() {
return this._commandState;
return $state.snapshot(this._commandState);
}

#scheduleUpdate() {
Expand All @@ -91,7 +91,7 @@ class CommandRootState {

if (hasStateChanged) {
this.commandState = currentState;
this.opts.onStateChange?.current?.($state.snapshot(currentState));
this.opts.onStateChange?.current?.(currentState);
}
});
}
Expand Down

0 comments on commit 5a4ae20

Please sign in to comment.