Skip to content

fix(dataeditor): settle column defaults and the cell callback at create time - #7607

Merged
masenf merged 5 commits into
mainfrom
claude/cool-ramanujan-2wpvc2
Oct 21, 2026
Merged

masenf merged 5 commits into
mainfrom
claude/cool-ramanujan-2wpvc2

Conversation

@masenf

@masenf masenf commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Description

closes #7596

DataEditor.create only applied the documented default column type and id to literal column lists. State-backed columns reached Glide untouched, so a column without a type produced an invalid text cell and crashed at render.

This replaces add_hooks with hooks carried on the vars assigned to the props, all created in create:

  • A state-backed column list is mapped through the defaults inside a useMemo keyed on it, so the mapping runs when the columns change rather than for every cell Glide draws. It takes the same shapes as the literal path, a title string or an object, and the memoized var is typed as the column dicts the mapping yields, so a list[str] of titles passes the prop check. The columns prop names that memoized list and still tracks the state field it comes from.
  • getCellContent is a useCallback over the rendered columns and data. Both dependency arrays list the vars each prop reads, through get_leaf_vars (feat(vars): add get_leaf_vars #7606): the state fields, loop vars and memo props behind it, down to those inside a literal such as [[value]] or a predicate, and none of the constants. So State.columns.filter(...) depends on State.columns alone, State.data[1:] on State.data, and all-literal columns and data on nothing.
  • formatDataEditorCells is imported by the hook that uses it instead of by add_imports.

Both hooks are created along with get_cell_content, so the component no longer mutates itself during rendering and nothing has to be stashed on the instance.

Column formatting moves into the data editor module as _format_column, which builds a new dict instead of modifying the caller's and fills in the default id only when none is given. reflex_base.utils.format.format_data_editor_column stays as a deprecated shim (0.10.1, removal 1.0) so an older data editor release keeps working against a newer base. The data editor is floored on reflex-base >= 0.10.1.dev0 for get_leaf_vars.

For rx.data_editor(columns=State.columns, data=State.data) the compiled component now holds:

const columns_x = useMemo(() => (state.columns).map((col) => typeof col === "string" ? { title: col, id: col.toLowerCase(), type: "str" } : { type: "str", id: (col.title ?? "").toLowerCase(), ...col }), [state.columns])
const getData_x = useCallback(([col, row]) => formatDataEditorCells(col, row, columns_x, state.data), [columns_x, state.data])

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

tests/units/components/datadisplay/test_dataeditor.py covers the literal defaults (explicit values win, a column with an id needs no title, input not modified), the rejected inputs, the generated callback name, the callback with and without dependencies, a memo prop inside a literal, the state-backed hooks in order with preserved var data, a list[str] state var of titles, derived props (a filter and a slice) depending on the vars they read, a literal var memoized once, and a Node run of the generated hooks against the real formatDataEditorCells helper that asserts the normalized columns and the cells for dict and array rows. tests/units/reflex_base/utils/test_format.py covers the deprecation shim.

A real app with a state-backed grid whose column has no type was compiled and loaded in headless Chromium: the rows render, and adding a row and an untyped column re-renders with no page errors.

ruff, pyright on the touched files, make_pyi.py --check, and the unit tests pass. check_min_deps.py could not run in this environment (shallow clone without reachable release tags); the data editor uses only reflex-base APIs present in 0.10.0 plus get_leaf_vars, now on main.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RqJ6TNt8AXzbDVm5kLb2nD

@masenf
masenf requested a review from a team as a code owner October 19, 2026 22:34
@masenf masenf mentioned this pull request Oct 19, 2026
8 tasks done

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Summary

DataEditor.create now sets column defaults and builds the cell callback before rendering.

  • Literal and state-backed columns reach the grid with usable defaults.
  • The cell reader stays stable until its columns or data change.
  • The shared column formatter warns callers to use the data editor.

Reviews (10) · Last reviewed commit: "fix(dataeditor): apply the defaults to a..." · Reviewed by Greptile

@codspeed

codspeed Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 12 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 148 untouched benchmarks


Comparing claude/cool-ramanujan-2wpvc2 (3d8345c) with main (d3f4ab1)

Open in CodSpeed

@masenf
masenf force-pushed the claude/cool-ramanujan-2wpvc2 branch 2 times, most recently from 761b58f to f12a9b7 Compare October 19, 2026 23:12
@masenf
masenf force-pushed the claude/cool-ramanujan-2wpvc2 branch 2 times, most recently from 8988e6e to 8eb0553 Compare October 20, 2026 00:40
@masenf masenf added the on deck PRs lined up to review / merge next label Oct 20, 2026
@masenf
masenf force-pushed the claude/cool-ramanujan-2wpvc2 branch from 8eb0553 to 1ff8832 Compare October 20, 2026 21:01
FarhanAliRaza
FarhanAliRaza previously approved these changes Oct 20, 2026
Base automatically changed from claude/get-leaf-vars to main October 20, 2026 22:33
@masenf
masenf dismissed FarhanAliRaza’s stale review October 20, 2026 22:33

The base branch was changed.

…te time

`DataEditor.create` only applied the documented default column `type` and
`id` to literal column lists. State-backed columns reached Glide untouched,
so a column without a `type` produced an invalid text cell and crashed at
render (#7596).

Replace `add_hooks` with hooks carried on the vars assigned to the props:

- A state-backed column list is mapped through the defaults inside a
  `useMemo` keyed on it, so the mapping runs when the columns change rather
  than for every cell Glide draws. It takes the same shapes as the literal
  path, a title string or an object. The columns prop names that memoized
  list and still tracks the state field it comes from.
- `getCellContent` is a `useCallback` over the rendered columns and data.
  Both dependency arrays list the leaf vars behind each prop, through
  `get_leaf_vars`, so a derived prop such as `State.columns.filter(...)`
  depends on `State.columns` alone. A literal or function carrying no var
  data is a constant expression and is left out.
- `formatDataEditorCells` is imported by the hook that uses it.

Both hooks are created in `create` along with `get_cell_content`, so the
component no longer mutates itself during rendering and no hoisted state has
to be stashed on the instance.

Column formatting moves into the data editor module as `_format_column`,
which builds a new dict instead of modifying the caller's. The old
`reflex_base.utils.format.format_data_editor_column` stays as a deprecated
shim so an older data editor release keeps working against a newer base.
The data editor is floored on reflex-base 0.10.1.dev0 for `get_leaf_vars`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RqJ6TNt8AXzbDVm5kLb2nD
The dependency arrays dropped a literal or function carrying no var data as
a constant, but a memo prop or loop var carries none either: an `@rx.memo`
component passing `data=[[value]]` got a `useCallback` with `[]` and kept
the first value. Now that `get_leaf_vars` reads through literal containers
and function bodies, the arrays list every var the props read, with no
heuristic left: `[[value]]` yields `value`, a predicate closing over nothing
yields nothing, and `State.data[1:]` yields `State.data`.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RqJ6TNt8AXzbDVm5kLb2nD
…nly columns

`_format_column` read `title` even when the column already carried an `id`,
so a literal column such as `{"id": "name", "type": "str"}` raised
`KeyError` where it used to pass through. Fill in the default `id` only
when none is given.

The memoized column var kept the input's type, so a state var of title
strings failed the prop type check before the mapping that turns titles
into column dicts could run. Type it as `Sequence[dict[str, Any]]`, which
is what the mapping yields whatever the input holds.

Tell a user who sees the `format_data_editor_column` deprecation what to
do: upgrade reflex-components-dataeditor, its only caller.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RqJ6TNt8AXzbDVm5kLb2nD
@masenf
masenf force-pushed the claude/cool-ramanujan-2wpvc2 branch from cf6d518 to cd97a00 Compare October 20, 2026 22:38

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

`_format_column` passes a var element through as is, so a literal list such
as `[{"title": "Name"}, State.extra]` handed Glide a column with no `type`,
the same crash the render-time defaults fix for a state-backed list. When a
literal list holds a var, route the whole list through that same `useMemo`
mapping; its dependencies are the vars the list reads, and the mapping
leaves the already formatted columns as they are.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RqJ6TNt8AXzbDVm5kLb2nD
@masenf
masenf merged commit ef761f7 into main Oct 21, 2026
169 checks passed
@masenf
masenf deleted the claude/cool-ramanujan-2wpvc2 branch October 21, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

on deck PRs lined up to review / merge next

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataEditor does not apply the default string type to reactive columns

3 participants