Skip to content

fix: position codeblock copy buttons relative to their codeblock - #111

Merged
LineIndent merged 1 commit into
LineIndent:mainfrom
elviskahoro:fix/codeblock-copy-button-positioning
Oct 21, 2026
Merged

LineIndent merged 1 commit into
LineIndent:mainfrom
elviskahoro:fix/codeblock-copy-button-positioning

Conversation

@elviskahoro

Copy link
Copy Markdown
Collaborator

The copy buttons in chart_util_wrapper and file_codeblock are absolutely positioned, but their ancestors had no position: relative, so the buttons anchored to the page root instead of staying pinned to the codeblock.

Adds relative to the wrapper class names, matching the pattern already used in demo_wrapper.

Fixes copy buttons in chart_util_wrapper and file_codeblock being
absolutely positioned without a positioned ancestor, which caused
them to anchor to the page root instead of the codeblock. Matches
the pattern already used in demo_wrapper. Closes AI-342.
@LineIndent
LineIndent merged commit 7de81b3 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_1b3baf3e-451f-46f0-aeb4-d714f753d804)

Closes #96

## Bug
`input(type="checkbox"/"number"/"range")` handed `on_change` a raw DOM
**string** (`e.target.value`) instead of the upstream-typed payload — a
**bool** (`e.target.checked`) for checkboxes and a coerced **number**
(`Number(e.target.value)`) for number/range.

Root cause: `InputComponent` subclasses upstream `Input` and delegates
via `super().create(...)`. Upstream `Input.create` only performs its
typed dispatch to `CheckboxInput`/`ValueNumberInput` under an `if cls is
Input` exact-class guard, so dispatch silently no-ops for the subclass —
every typed input fell through to the plain `input_event` (string)
payload. Introduced when the wrapper became an `Input` subclass.

## Fix
`components/ui/input.py` now replicates the upstream `type` dispatch to
`CheckboxInput`/`ValueNumberInput` after applying buridan-ui's
`data_slot`/`class_name` styling, then delegates to the typed component
(matching the upstream contract that direct `BaseInput.create(type=...)`
already exposed).

The dispatch target classes are not `CoreComponent`s, so they don't
strip buridan-ui's `unstyled` prop the way `InputComponent` does.
Without care, `unstyled` would siphon into the rendered `css` style dict
on the typed element. The wrapper therefore `pop`s `unstyled` before
delegating, preserving the existing `unstyled` contract (and the
`render_` early-return path of `set_class_name`) for typed inputs. A
`cast(BaseInput, ...)` reconciles the sibling-class return with the
inherited `Input.create` signature so pyright stays clean.

## Testing
- New unit tests in `tests/test_input.py` cover: typed inputs return
`CheckboxInput`/`ValueNumberInput` with
`BooleanCastedVar`/`NumberCastedVar` `on_change` args;
text/email/password/file and the default-type path stay `InputComponent`
with `StringCastedVar` (no over-dispatch); the dispatch still forwards
`data_slot` and the default `class_name`; `unstyled` is not forwarded to
the typed component (exercising the `render_` early-return path via a
`set_class_name` no-op monkeypatch) and does not leak onto the rendered
DOM; and the wrapper's classes/arg types match upstream
`BaseInput.create(type=...)` exactly.
- End-to-end: stood up a minimal Reflex app importing the repo's
`components.ui.input`, ran the dev server, and inspected the live-served
compiled bundle. The shipped `onChange` handlers bind
`Number(_e?.["target"]?.["value"])` for number/range and
`_e?.["target"]?.["checked"]` for checkbox; the `unstyled` checkbox
renders only `{className, data-slot, id, onChange, ref, type}` with no
`unstyled` prop or `css`/`style` leak.
- Routine checks: unit tests, full repo suite, pyright, and ruff
format/lint all pass; regenerated `assets/docs/components/input.md` to
keep the install snippet in sync with the source (required by the
asset-sync gate).

---
_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: pullfrog[bot] <226033991+pullfrog[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