Fix ReflexEvent argument order for client_handler_name in format_event

Merged
FA
3mo ago
+36-1

Summary

format_event() in reflex_base/utils/format.py appended client_handler_name as the third positional argument of ReflexEvent(...), but the JS constructor in .templates/web/utils/state.js is ReflexEvent(name, payload, event_actions, handler) — event_actions is third and handler is fourth.

As a result, for any EventSpec with a non-empty client_handler_name formatted through format_event, the handler string landed in the event_actions slot and e.handler stayed null, so the event.handler === "uploadFiles" routing in applyRestEvent could never fire.

Real-world impact

client_handler_name is set to "uploadFiles" by rx.upload_files / rx.upload_files_chunk specs. Such a spec flows through format_queue_events → format_event when used as:

  • a rx.call_script / rx.call_function callback
  • a toast action / cancel button on_click (or on_dismiss / on_auto_close)

In those contexts the upload would silently never start.

Fix

Emit event_actions (as JSON) third and client_handler_name fourth, matching the already-correct pattern in LiteralEventVar.create. Output for specs without a client_handler_name is byte-identical to before, so no other compiled output changes.

Test

Regression test test_format_event_client_handler_name in tests/units/test_event.py — fails before the fix (handler string in the third slot), passes after.