Skip to content

fix: preserve custom styling on context menu shortcuts - #115

Merged
LineIndent merged 1 commit into
LineIndent:mainfrom
elviskahoro:fix/context-menu-shortcut-styling
Oct 21, 2026
Merged

LineIndent merged 1 commit into
LineIndent:mainfrom
elviskahoro:fix/context-menu-shortcut-styling

Conversation

@elviskahoro

Copy link
Copy Markdown
Collaborator

ContextMenuShortcut.create unconditionally overwrote props["class_name"], so a caller-provided class_name was silently dropped and never reached the rendered component.

Uses cls.set_class_name(...) instead so custom classes merge with the defaults, consistent with the other menu components. Adds tests/test_context_menu.py covering the default, merged, and unstyled cases.

@LineIndent
LineIndent merged commit cae6190 into LineIndent:main Oct 21, 2026
1 check passed
elviskahoro added a commit that referenced this pull request Nov 10, 2026
#115)

**Detail bug report:** [View on
Detail](https://app.detail.dev/org_d38a878f-9df9-4c4b-a96a-f5180b860085/bugs/bug_5ad87135-0dfa-469c-9e9c-bc9731cbd28b)

Closes #100

## Bug

`card_twenty_two` ("Financial Ledger") and `card_twenty_six`
("Medication Record") build their tables from the low-level `table.root`
primitives and passed `striped=True` to opt into zebra striping. But
`striped` is only a declared parameter of the high-level `table(...)`
builder — `TableRoot.create` captures it in `**props` and forwards it to
`Div.create`, where Reflex stores it on the component's `style` dict. It
renders as an Emotion `css:({ ["striped"] : true })` rule that browsers
silently discard (the `striped` CSS property is unknown), so the cards
shipped with no visible striping and a dead `striped=True` argument.

## Fix

Since these cards build rows manually (with per-cell styling the
high-level builder can't reproduce), the idiomatic fix is to apply the
striping utility directly to each body row and remove the inert kwarg:

- Added `class_name="even:bg-secondary/30"` to each body
`table.row(...)` in both cards — the same utility
`HighLevelTable.create` emits for striped tables.
- Removed the inert `striped=True` from both `table.root(...)` calls.

The `even:` variant is a `:nth-child(even)` selector, so attaching it to
every body row produces the same visual alternation as the high-level
builder (rows 2, 4, … shaded).

## Testing

- **Unit tests (versioned):** 4 tests in `tests/test_table_striping.py`
guard the invariants going forward — a render-level assert on
`card_twenty_two()` pins zebra striping on the fixed card, the
high-level `table(...)` builder honors `striped=True` and consumes it
(never leaking it), defaults to no striping, and a tripwire confirming
`table.root(...)` does **not** handle `striped` (so a future change to
that API is deliberate, not silent).
- **Routine checks:** full suite, pyright, and ruff all pass.
- **Browser verification:** rendered a standalone page with the
project's compiled Tailwind CSS and the actual row class names from the
fix. Striped rows 2 and 4 render `oklch(0.97 0 0 / 0.3)` backgrounds
(the `color-mix(in oklab, var(--secondary) 30%, transparent)` rule),
rows 1 and 3 stay transparent, no `striped` CSS property appears
anywhere in the DOM, and a control table without the striping class has
uniform backgrounds.
- **Live app:** the Reflex `/components` page could not be verified
end-to-end due to a pre-existing React hydration error that prevents all
masonry card content from rendering. Confirmed unrelated — the
server-rendered HTML is byte-identical with and without this change.

---
_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>
Co-authored-by: elvis kahoro <github@elvis.ai>
elviskahoro added a commit that referenced this pull request Nov 10, 2026
…bare indicators (#265)

## Summary

Scoped to `components/ui/context_menu.py` and its tests. Works through
three `detail-app` bug reports in order, closing the two that still
applied:

- Closes #83 —
`ContextMenuItem`/`GroupLabel`/`RadioItem`/`CheckboxItem`/`SubmenuTrigger`
gated the `inset`/`variant` → `data-*` rewrite with `if
props.get("inset"):` / `if props.get("variant"):`. That's a truthiness
check, and Reflex's `Var.__bool__` raises `VarTypeError`
unconditionally, so passing a state `Var` for either prop crashed
app-definition time. Switched to presence checks (`"inset" in props`,
`"variant" in props`) so both literal values and bound `Var`s work,
matching the pattern already used in `tabs.py`.
- Closes #221 — `ContextMenuRadioItemIndicator` /
`ContextMenuCheckboxItemIndicator` rendered an empty span when called
bare (no children), unlike every sibling indicator wrapper in the repo
(`menu.py`, `select.py`, `checkbox.py`), which inject a default tick.
Checked radio/checkbox items following the documented bare-indicator
composition showed no visible checkmark. Now injects `hi("Tick02Icon")`
when no children are supplied, while still preserving any
explicitly-passed custom icon.
- **Duplicate/already resolved: #37** — `ContextMenuShortcut`
overwriting `class_name` instead of merging it (and ignoring `unstyled`)
was already fixed by `cae6190` ("Preserve custom styling on context menu
shortcuts (#115)"), which also added regression tests
(`test_context_menu_shortcut_*`) currently in
`tests/test_context_menu.py`. No code change needed for #37; verified
the existing tests still pass.

## Test plan

- [x] Added regression tests in `tests/test_context_menu.py`:
- `inset`/`variant` accept a `rx.State` `Var` without raising, for all
five affected components, and still accept plain literals (#83)
- Bare `radio_item_indicator()` / `checkbox_item_indicator()` render a
default tick icon, and a custom icon passed as a child is preserved, not
duplicated (#221)
- [x] `uv run pytest tests/` — 1277 passed, 4 skipped (full suite, no
regressions)
- [x] `uv run ruff check components/ui/context_menu.py` — clean
- [x] `trunk check components/ui/context_menu.py
tests/test_context_menu.py` — no new issues (pre-existing
`semgrep`-ignored notices only)
- [x] Regenerated `assets/docs/components/context-menu.md` via
`scripts/generate_markdown.py` so the doc's embedded source snippet
stays in sync (caught by `tests/test_generated_assets.py`)

No lint config changes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- conductor-workspace-link -->

---

[Open workspace in
Conductor](https://app.conductor.build/elviskahoro-cloud/w/701)

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.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