Skip to content

docs: events, storage, and component field notes#6779

Open
amsraman wants to merge 3 commits into
mainfrom
docs/events-storage-field-notes
Open

docs: events, storage, and component field notes#6779
amsraman wants to merge 3 commits into
mainfrom
docs/events-storage-field-notes

Conversation

@amsraman

Copy link
Copy Markdown
Contributor

Fourth batch of upstreaming Reflex Build's AI-builder knowledge base (#6775, #6777, and the recharts batch). Events/storage/component gaps:

  • event_triggers: on_key_down/on_key_up sections (keyboard triggers were previously undocumented) and a Global Keyboard Events section for rx.window_event_listener (also undocumented)
  • memo: Using with rx.foreach (lambda + keyword args; the key prop forwarding — verified against reflex_base source)
  • text_area: Submitting on Enter (enter_key_submit, Shift+Enter behavior, and a verified warning that it can't be combined with on_key_down — raises ValueError)
  • special_events: set_clipboard with state Vars, backend rx.download(data=...) example, auto_scroll cross-link
  • page_load_events: loading/error handling pattern (yield-for-immediate-loading-state, try/except/finally)
  • browser_storage: local-storage positional-default callout

Notably, three knowledge-base claims were checked against source and rejected rather than upstreamed (rx.get_clipboard doesn't exist; .temporal doesn't guarantee ordering; sync isn't default-on). Pre-commit clean.

🤖 Generated with Claude Code

Keyboard event triggers (on_key_down/on_key_up) and global hotkeys via
rx.window_event_listener (previously undocumented), memo-with-foreach
patterns, enter_key_submit with its on_key_down conflict, set_clipboard
with state vars, backend rx.download, on_load loading/error handling,
and a local-storage positional-default note. Three stale knowledge-base
claims were verified against source and rejected rather than upstreamed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@amsraman
amsraman requested review from a team and Alek99 as code owners July 15, 2026 23:06
@codspeed-hq

codspeed-hq Bot commented Jul 15, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 26 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing docs/events-storage-field-notes (7939967) with main (7e80931)2

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (fed116f) during the generation of this report, so 7e80931 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@greptile-apps

greptile-apps Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds six documentation sections across event triggers, browser storage, special events, page-load events, text area, and memo — the fourth batch of upstreaming knowledge from the Reflex Build AI-builder knowledge base.

  • event_triggers.md documents on_key_down/on_key_up with working demos and a new Global Keyboard Events section for rx.window_event_listener.
  • text_area.md covers enter_key_submit with a live demo, Var-toggling note, and a source-verified warning that combining it with on_key_down raises a ValueError.
  • memo.md adds a rx.foreach example using rx.RestProp to forward key without triggering the 0.9.3 deprecation warning (fixed per prior review thread).
  • special_events.md adds an rx.auto_scroll cross-link, a Var-based rx.set_clipboard demo, and a backend rx.download(data=…) example.
  • page_load_events.md adds an async loading/error pattern using a loading flag, yield, and try/except/finally.
  • browser_storage.md adds a positional-default callout for all three storage types.

Confidence Score: 5/5

Safe to merge — all changes are documentation additions with no functional code changes; examples have been verified against source.

All six files contain only documentation additions. The examples are consistent with the described behaviors, and the three knowledge-base claims that could not be verified were explicitly excluded. The one minor inaccuracy — max_age listed as a sample keyword arg for all three storage types when it is Cookie-only — is trivially correctable and does not affect correctness elsewhere.

docs/api-reference/browser_storage.md — the positional-default callout lists max_age as an example keyword for LocalStorage and SessionStorage, where it does not apply.

Important Files Changed

Filename Overview
docs/api-reference/browser_storage.md Adds a positional-default callout for rx.Cookie/LocalStorage/SessionStorage; max_age listed as an example keyword arg for all three types even though it is Cookie-only.
docs/api-reference/event_triggers.md Adds on_key_down/on_key_up sections and a Global Keyboard Events section for rx.window_event_listener; examples look accurate and consistent.
docs/api-reference/special_events.md Adds auto_scroll cross-link under rx.scroll_to, a Var-based rx.set_clipboard demo, and a backend rx.download(data=...) demo; all additions are accurate and runnable.
docs/events/page_load_events.md Adds a loading/error handling pattern with async handler, loading flag, yield, and try/except/finally; pattern is idiomatic and correct.
docs/library/forms/text_area.md Documents enter_key_submit prop with a live demo, Var-toggling note, and a verified warning about the on_key_down conflict; all claims align with the stated source check.
docs/library/other/memo.md Adds rx.foreach section using the rx.RestProp pattern (fixed from the prior review thread) so key forwards correctly without triggering a deprecation warning.

Reviews (3): Last reviewed commit: "docs: correct the enter_key_submit / on_..." | Re-trigger Greptile

Comment thread docs/library/other/memo.md

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 96b2fe3316

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/library/other/memo.md Outdated


@rx.memo
def task_card(task: rx.Var[Task]) -> rx.Component:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid documenting deprecated key forwarding

When users copy this rx.foreach example, the later key=... is passed to a memo that has no rx.RestProp. The runtime explicitly treats that as legacy and calls _warn_legacy_base_props when rest_param is None (packages/reflex-base/src/reflex_base/components/memo.py:1630-1643), with the deprecation message saying to declare rx.RestProp for base props (packages/reflex-base/src/reflex_base/components/memo.py:1869-1878). This doc therefore recommends a pattern that immediately emits a deprecation warning and is scheduled for removal; include and pass a RestProp while still not declaring key as an explicit prop, or call out the warning.

Useful? React with 👍 / 👎.

Comment thread docs/library/forms/text_area.md Outdated
Comment on lines +136 to +139
The `enter_key_submit` prop is implemented with its own key down handler, so
passing both to the same component raises an error. If custom key handling is
needed, implement the Enter-to-submit behavior in your own `on_key_down`
handler instead.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Don't suggest on_key_down can replace enter_key_submit

In the case where a textarea also needs custom key handling, this fallback tells users to implement the Enter-submit behavior with a normal Reflex on_key_down, but the built-in implementation needs the raw JS event to call e.preventDefault() and e.target.form.requestSubmit() (packages/reflex-components-core/src/reflex_components_core/el/elements/forms.py:870-877), while the public key event only sends the key and modifier Vars to state handlers (packages/reflex-base/src/reflex_base/event/__init__.py:1028-1045). Following this advice still lets Enter insert a newline, and using .prevent_default would suppress all key input rather than only Enter, so the docs should point to a custom JS custom_attrs handler or another supported pattern.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Verified and fixed. Confirmed against the Reflex source: on_key_down uses key_event, which passes only (key, {alt/ctrl/meta/shift}) to the Python handler — the raw event is consumed and never forwarded, so preventDefault() / requestSubmit() aren't reachable and the newline would still be inserted. Corrected the note: a Python on_key_down handler can't stop the newline, and replicating Enter-to-submit with custom key handling needs a client-side handler (e.g. rx.call_script), not a plain on_key_down. Thanks for the catch.

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