Skip to content

Commit

Permalink
next: fix untrack cleanups (#746)
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte authored Oct 8, 2024
1 parent bd3e9b8 commit 6e14ca6
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-islands-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"bits-ui": patch
---

fix: cleanup a few untracks that were left unhandled
2 changes: 1 addition & 1 deletion packages/bits-ui/src/lib/bits/command/command.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ class CommandItemState {
this.id.current;
this.#group?.id.current;
if (!this.#forceMount.current) {
untrack(() => {
return untrack(() => {
return this.root.registerItem(this.id.current, this.#group?.id.current);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class PinInputRootState {

$effect(() => {
let unsub = noop;
untrack(() => {
return untrack(() => {
const input = this.#inputRef.current;
const container = this.#ref.current;

Expand Down
2 changes: 1 addition & 1 deletion packages/bits-ui/src/lib/bits/select/select.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ export class SelectContentState {

$effect(() => {
this.root.open.current;
untrack(() => {
return untrack(() => {
let cleanup = [noop];

afterTick(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/bits-ui/src/lib/bits/tabs/tabs.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class TabsTriggerState {
const id = this.#id.current;
const value = this.#value.current;

untrack(() => {
return untrack(() => {
const deregister = this.#root.registerTrigger(id, value);
return () => {
deregister();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,10 @@ export function useFocusScope({

return () => {
if (!container) return;
container.removeEventListener(
AUTOFOCUS_ON_MOUNT,
untrack(() => onOpenAutoFocus.current)
);
container.removeEventListener(AUTOFOCUS_ON_MOUNT, onOpenAutoFocus.current);

const destroyEvent = new CustomEvent(AUTOFOCUS_ON_DESTROY, EVENT_OPTIONS);
container.addEventListener(
AUTOFOCUS_ON_DESTROY,
untrack(() => onCloseAutoFocus.current)
);
container.addEventListener(AUTOFOCUS_ON_DESTROY, onCloseAutoFocus.current);
container.dispatchEvent(destroyEvent);

setTimeout(() => {
Expand Down

0 comments on commit 6e14ca6

Please sign in to comment.