Skip to content
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

next: fix untrack cleanups #746

Merged
merged 2 commits into from
Oct 8, 2024
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/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