{"record":{"id":"f95719b8ac8b1c7f","repo":"reflex-dev/reflex","slug":"cannot-combine-enter-key-submit-with-on-key-dow","errorCode":null,"errorMessage":"Cannot combine `enter_key_submit` with `on_key_down`.","messagePattern":"Cannot combine `enter_key_submit` with `on_key_down`\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-components-core/src/reflex_components_core/el/elements/forms.py","lineNumber":982,"sourceCode":"        Args:\n            *children: The children of the textarea.\n            **props: The properties of the textarea.\n\n        Returns:\n            The textarea component.\n\n        Raises:\n            ValueError: when `enter_key_submit` is combined with `on_key_down`.\n        \"\"\"\n        enter_key_submit = props.get(\"enter_key_submit\")\n        auto_height = props.get(\"auto_height\")\n        custom_attrs = props.setdefault(\"custom_attrs\", {})\n\n        if enter_key_submit is not None:\n            enter_key_submit = Var.create(enter_key_submit)\n            if \"on_key_down\" in props:\n                msg = \"Cannot combine `enter_key_submit` with `on_key_down`.\"\n                raise ValueError(msg)\n            custom_attrs[\"on_key_down\"] = Var(\n                _js_expr=f\"(e) => enterKeySubmitOnKeyDown(e, {enter_key_submit!s})\",\n                _var_data=VarData.merge(enter_key_submit._get_all_var_data()),\n            )\n        if auto_height is not None:\n            auto_height = Var.create(auto_height)\n            custom_attrs[\"on_input\"] = Var(\n                _js_expr=f\"(e) => autoHeightOnInput(e, {auto_height!s})\",\n                _var_data=VarData.merge(auto_height._get_all_var_data()),\n            )\n        return super().create(*children, **props)\n\n    def _exclude_props(self) -> list[str]:\n        return [\n            *super()._exclude_props(),\n            \"auto_height\",\n            \"enter_key_submit\",\n        ]","sourceCodeStart":964,"sourceCodeEnd":1000,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-components-core/src/reflex_components_core/el/elements/forms.py#L964-L1000","documentation":"rx.el.text_area's enter_key_submit helper installs its own on_key_down handler; passing on_key_down explicitly would conflict, so Reflex rejects the combination.","triggerScenarios":"Calling rx.el.text_area(..., enter_key_submit=True, on_key_down=State.handle_key) — both props target the same DOM event.","commonSituations":"Adding custom keyboard shortcuts (e.g. Escape to clear) to a textarea that already uses enter_key_submit for chat-style submit behavior.","solutions":["Drop on_key_down and implement key handling inside a single custom on_key_down that also calls enterKeySubmitOnKeyDown logic","Or drop enter_key_submit and pass on_key_down=(e) => enterKeySubmitOnKeyDown(e, handler) plus your logic via a custom handler","Use a wrapping div with its own key handler for non-conflicting keys"],"exampleFix":"# before\nrx.el.text_area(enter_key_submit=True, on_key_down=State.on_key)\n# after\nrx.el.text_area(enter_key_submit=True, on_blur=State.on_blur)  # or move key handling into a single custom on_key_down","handlingStrategy":"validation","validationCode":"if enter_key_submit and 'on_key_down' in kwargs:\n    raise ValueError('pick one: enter_key_submit or custom on_key_down')\nrx.el.text_area(..., **kwargs)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat enter_key_submit as owning on_key_down; don't pass both","Implement combined key logic in a single custom on_key_down handler"],"tags":["reflex","textarea","event-conflict"],"backgroundTag":"conflicting-event-handlers","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}