Skip to content

Commit 14f28db

Browse files
authored
fix: segmented control not transitioning after first render (#718)
1 parent 6e35520 commit 14f28db

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

.changeset/poor-seals-cross.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@zag-js/radio-group": patch
3+
---
4+
5+
Fix segmented control not transitioning after first render

packages/machines/radio-group/src/radio-group.machine.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export function machine(userContext: UserDefinedContext) {
1313
id: "radio",
1414
initial: "idle",
1515
context: {
16-
previousValue: null,
1716
value: null,
1817
activeId: null,
1918
focusedId: null,
@@ -96,11 +95,8 @@ export function machine(userContext: UserDefinedContext) {
9695
input.checked = input.value === ctx.value
9796
})
9897
},
99-
setPreviousValue(ctx) {
100-
ctx.previousValue = ctx.value
101-
},
10298
setIndicatorTransition(ctx) {
103-
ctx.canIndicatorTransition = isString(ctx.previousValue) && isString(ctx.value)
99+
ctx.canIndicatorTransition = isString(ctx.value)
104100
},
105101
cleanupObserver(ctx) {
106102
ctx.indicatorCleanup?.()

packages/machines/radio-group/src/radio-group.types.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ type PrivateContext = Context<{
8181
* Function to clean up the observer for the active tab's rect
8282
*/
8383
indicatorCleanup?: VoidFunction | null
84-
/**
85-
* @internal
86-
* The previous value of the radio group
87-
*/
88-
previousValue: string | null
8984
}>
9085

9186
export type UserDefinedContext = RequiredBy<PublicContext, "id">

0 commit comments

Comments
 (0)