Skip to content

Commit 8443a9c

Browse files
committed
fix: accordion focus sync
1 parent e79ba4d commit 8443a9c

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

.changeset/ready-falcons-buy.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@zag-js/accordion": patch
3+
---
4+
5+
Fix issue in Safari where clicking triggers doesn't show the content as expected.

packages/machines/accordion/src/accordion.connect.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,8 @@ export function connect<T extends PropTypes>(
105105
"data-state": itemState.expanded ? "open" : "closed",
106106
"data-ownedby": dom.getRootId(scope),
107107
onFocus() {
108-
queueMicrotask(() => {
109-
if (itemState.disabled) return
110-
send({ type: "TRIGGER.FOCUS", value })
111-
})
108+
if (itemState.disabled) return
109+
send({ type: "TRIGGER.FOCUS", value })
112110
},
113111
onBlur() {
114112
if (itemState.disabled) return

packages/machines/accordion/src/accordion.machine.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const machine = createMachine<AccordionSchema>({
2424
return {
2525
focusedValue: bindable<string | null>(() => ({
2626
defaultValue: null,
27+
sync: true,
2728
onChange(value) {
2829
prop("onFocusChange")?.({ value })
2930
},

0 commit comments

Comments
 (0)