internal: Make the Demo Form Accept Extra on_submit Handlers#6486
Conversation
Greptile SummaryThis PR exposes an
Confidence Score: 3/5The change is small and well-scoped, but the handler-normalisation logic only recognises Python lists, so callers who pass a tuple of handlers will have their handlers silently mis-applied. The normalization expression uses isinstance(on_submit, list) to detect multi-handler input, but Reflex also accepts tuples as multi-handler sequences. A tuple passed here skips the branch and gets wrapped as a single element, meaning the individual handlers inside it are never registered separately — a silent functional failure for any caller who uses tuple syntax. packages/reflex-components-internal/src/reflex_components_internal/blocks/demo_form.py — specifically the extra_on_submit normalisation block (lines 294–296). Important Files Changed
Sequence DiagramsequenceDiagram
actor User
participant Form as rx.el.form
participant PostHog as DemoFormStateUI.track_demo_form_posthog
participant Dialog as demo_form_open_cs (ClientState)
participant Extra as extra_on_submit handlers
User->>Form: Submit
Form->>PostHog: on_submit[0] — PostHog track
PostHog-->>Form: done
Form->>Dialog: on_submit[1] — set_value(False) → close dialog
Dialog-->>Form: done
Form->>Extra: on_submit[2..n] — caller-provided handlers
Extra-->>Form: done
Reviews (1): Last reviewed commit: "Internal Demo Form accepts extra on_subm..." | Re-trigger Greptile |
| extra_on_submit = ( | ||
| on_submit if isinstance(on_submit, list) else [on_submit] if on_submit else [] | ||
| ) |
There was a problem hiding this comment.
isinstance check doesn't handle tuple event-handler lists
Reflex allows event handler collections to be passed as either a list or a tuple. If a caller passes on_submit as a tuple (e.g., on_submit=(HandlerA, HandlerB)), isinstance(on_submit, list) returns False, so the entire tuple is wrapped in another list as a single element — meaning *extra_on_submit spreads (HandlerA, HandlerB) as one item instead of two separate handlers. Reflex would then try to interpret the tuple as a single handler and likely raise a runtime error or silently ignore it.
| extra_on_submit = ( | |
| on_submit if isinstance(on_submit, list) else [on_submit] if on_submit else [] | |
| ) | |
| extra_on_submit = ( | |
| list(on_submit) | |
| if isinstance(on_submit, (list, tuple)) | |
| else [on_submit] | |
| if on_submit | |
| else [] | |
| ) |
There was a problem hiding this comment.
tuples aren't accepted as part of that type, right?
Merging this PR will not alter performance
Comparing Footnotes
|
All Submissions:
Type of change
Please delete options that are not relevant.
New Feature Submission:
Changes To Core Features:
After these steps, you're ready to open a pull request.