Skip to content

fix: allow reactive variables as range steps - #7914

Open
peterolkhov wants to merge 2 commits into
reflex-dev:mainfrom
peterolkhov:codex/fix-reactive-range-step
Open

peterolkhov wants to merge 2 commits into
reflex-dev:mainfrom
peterolkhov:codex/fix-reactive-range-step

Conversation

@peterolkhov

@peterolkhov peterolkhov commented Nov 16, 2026 •

Copy link
Copy Markdown

rx.Var.range(0, 10, State.step) passes the input validation, then raises VarTypeError while constructing foreach/grid because step or 1 evaluates the reactive variable as a Python boolean.

Default only when the step is None, preserving the supplied variable and its state dependencies. Added a parameterized regression for public/array constructors, state/literal variables, both stride directions and an empty range. Each case constructs the real grid and compares the generated JavaScript result with Python range. Includes a reflex-base news fragment.

All Submissions

  • Followed contribution guidelines; validation scope below.
  • Checked existing PRs for this change.

Type of change

  • Bug fix

Changes To Core Features

  • Explained the change and why it is needed.
  • Added regression tests that fail on the original source.
  • Ran affected tests locally.

Zero steps keep the existing stride-of-one fallback, including state values that change to zero after construction.

Validation: 604 affected tests passed, affected Pyright has zero errors, pinned Ruff check/format pass across the repository, and the genuine changed-file pre-commit command passes.

The full unit/coverage and browser suites were not run. The earlier all-files hook run had baseline type errors; a fresh full all-files run was not repeated for this revision. The required changed-file gate passes, including its always-run type checks.

View guided diff

@peterolkhov
peterolkhov requested a review from a team as a code owner November 16, 2026 23:57
@greptile-apps

greptile-apps Bot commented Nov 16, 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

Allows reactive range steps while keeping the default stride of one for omitted or zero steps.

  • Ranges keep reactive steps and use stride one when a step is zero.

No new actionable issues found.

Reviews (2) · Last reviewed commit: "fix: allow reactive variables as range s..." · Reviewed by Greptile

@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 3 files

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

View guided diff | Re-trigger cubic

This branch has not been deployed

No deployments
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.

1 participant