Skip to content

fix: restore button group separator spacing for orientation attributes - #116

Merged
LineIndent merged 1 commit into
LineIndent:mainfrom
elviskahoro:fix/button-group-separator-spacing
Oct 21, 2026
Merged

LineIndent merged 1 commit into
LineIndent:mainfrom
elviskahoro:fix/button-group-separator-spacing

Conversation

@elviskahoro

Copy link
Copy Markdown
Collaborator

The separator styling used data-horizontal: / data-vertical: variants, which don't match the data-orientation="horizontal|vertical" attributes actually emitted by Base UI — so separators rendered without their spacing.

Switches to data-[orientation=horizontal]: / data-[orientation=vertical]: selectors so the margin/width/height rules apply again.

@LineIndent
LineIndent merged commit 6bed71b into LineIndent:main Oct 21, 2026
1 check passed
elviskahoro pushed a commit that referenced this pull request Oct 25, 2026
**Detail bug report:** [View on
Detail](https://app.detail.dev/org_d38a878f-9df9-4c4b-a96a-f5180b860085/bugs/bug_8b90eeca-66ae-45f0-89cd-3a98e14753fa)

Closes #116

## Bug
`TooltipTrigger.create(render_=..., unstyled=<Var[bool]>)` raised an
unrecoverable `VarTypeError` at component construction (`reflex
run`/`reflex export` compile time). The regression was introduced in
#66, which set `TooltipTrigger._merge_default_classes_with_render =
True` to forward the trigger's default centering classes onto custom
`render_` targets. That flag removed the `render_` early-return shield
in `CoreComponent.set_class_name`, so a `Var[bool]` passed as `unstyled`
reached the pre-existing `if props.pop("unstyled", False):` line and was
evaluated via Python `bool(<Var>)`, which Reflex forbids.

The same `if <Var>:` truthiness defect also crashed the non-`render_`
path (`TooltipTrigger.create(unstyled=<Var>)`) before #66 — the
underlying defect is pre-existing and affects every `CoreComponent`. #66
simply turned a tolerated no-op into a crash for the `render_` + `Var`
combination.

## Fix
Rewrote `CoreComponent.set_class_name` (`components/ui/core.py`) so it
never evaluates a Reflex `Var` in a Python boolean context:
- Pops `unstyled` once (default `None`) instead of `pop(..., False)`
inside `if`.
- Handles the documented literal-`True` escape hatch via an identity
check (`unstyled is True`), preserving the existing behavior covered by
#66's tests.
- Routes dynamic `Var[bool]` values through `rx.cond(unstyled,
props_class_name, merged)` so the escape hatch is honored at React
render time instead of crashing at compile time.

This fixes both the #66 regression (`render_` + `Var`) and the
pre-existing `Var`-without-`render_` route with one change. Sibling
components that still rely on the `render_` early-return shield
(`TooltipPopup`, `AccordionTrigger`, `DialogClose`, `CollapsiblePanel`,
`CollapsibleTrigger`) are unaffected —
`_merge_default_classes_with_render` stays `False` for them.

## Testing
- **Unit tests (committed):** added 5 regression tests to
`tests/test_tooltip.py` covering: `render_` + `Var` no-crash;
no-`render_` + `Var` no-crash; the dynamic toggle emits an `rx.cond`
ternary with the caller's class in both branches and the defaults in the
false branch; the no-`render_` + custom-class + `Var` toggle preserves
the caller's class; and the still-shielded `TooltipPopup` + `render_` +
`Var` path tolerates the state var. All 9 tooltip tests pass; the full
suite remains green (829 passed).
- **Routine checks:** pyright reports 0 errors on the touched files;
`ruff format --check` is clean; `ruff check` surfaces only a
pre-existing `RUF012` on `BaseUIComponent.lib_dependencies` (line 58,
present on clean HEAD — out of scope); docs/assets generation produces
no new drift attributable to the fix.
- **End-to-end (not versioned):** registered a temporary page exercising
a state-driven dynamic `unstyled` tooltip, the literal-`True` case, and
the defaults case. With the fix reverted, `reflex compile` crashed with
the exact `VarTypeError` from the report; with the fix, it compiled
successfully. A Playwright run against the dev server confirmed the
trigger's `className` switched from `inline-flex items-center
justify-center` (merged defaults) to `""` (unstyled) when the state flag
was toggled in the browser, confirming the `rx.cond` ternary is reactive
at runtime. The temporary page and a one-off `enable_state=True` flip
needed to mount state at runtime were reverted; the final diff is
isolated to the fix and its tests.

---
_Automatic Fixes PRs can be [configured
here](https://app.detail.dev/org_d38a878f-9df9-4c4b-a96a-f5180b860085/settings/repos/repo_04b9d58c-daa0-46b6-9560-7f39569ec6eb/bugs)._

---------

Co-authored-by: detail-app[bot] <180357370+detail-app[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants