Skip to content

Commit 3e745c1

Browse files
authored
fix(tabs,radio-group): no longer show indicator prematurely (#2877)
1 parent 0792916 commit 3e745c1

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

.changeset/cyan-wolves-travel.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@zag-js/radio-group": patch
3+
"@zag-js/tabs": patch
4+
---
5+
6+
bugfix: `tabs` and `radio-group` machine no longer show the `indicator` prematurely

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,12 @@ export function connect<T extends PropTypes>(
196196

197197
getIndicatorProps() {
198198
const rect = context.get("indicatorRect")
199+
const rectIsEmpty = rect == null || (rect.width === 0 && rect.height === 0 && rect.x === 0 && rect.y === 0)
199200
return normalize.element({
200201
id: dom.getIndicatorId(scope),
201202
...parts.indicator.attrs,
202203
dir: prop("dir"),
203-
hidden: context.get("value") == null || rect == null,
204+
hidden: context.get("value") == null || rectIsEmpty,
204205
"data-disabled": dataAttr(groupDisabled),
205206
"data-orientation": prop("orientation"),
206207
style: {

packages/machines/tabs/src/tabs.connect.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,13 @@ export function connect<T extends PropTypes>(service: Service<TabsSchema>, norma
192192

193193
getIndicatorProps() {
194194
const rect = context.get("indicatorRect")
195+
const rectIsEmpty = rect == null || (rect.width === 0 && rect.height === 0 && rect.x === 0 && rect.y === 0)
195196
return normalize.element({
196197
id: dom.getIndicatorId(scope),
197198
...parts.indicator.attrs,
198199
dir: prop("dir"),
199200
"data-orientation": prop("orientation"),
200-
hidden: rect == null,
201+
hidden: rectIsEmpty,
201202
style: {
202203
"--transition-property": "left, right, top, bottom, width, height",
203204
"--left": toPx(rect?.x),

0 commit comments

Comments
 (0)