Skip to content

Commit cf8333b

Browse files
committed
fix: Textarea enter_key_submit uses add_custom_code instead of _get_all_custom_code
The Textarea component's auto_height and enter_key_submit features relied on overriding _get_all_custom_code to inject JavaScript helper functions. However, the compiler's builtin plugin collects custom code via _get_custom_code (singular) and add_custom_code, not _get_all_custom_code (plural). This caused both autoHeightOnInput and enterKeySubmitOnKeyDown to be missing from compiled pages, resulting in ReferenceError at runtime. Fix by implementing add_custom_code (the intended mechanism for injecting module-level JS) and removing the _get_all_custom_code override, since the parent class already merges add_custom_code results into _get_all_custom_code. Fixes #6482
1 parent 941f9bb commit cf8333b

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

  • packages/reflex-components-core/src/reflex_components_core/el/elements

packages/reflex-components-core/src/reflex_components_core/el/elements/forms.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -769,18 +769,22 @@ def _exclude_props(self) -> list[str]:
769769
"enter_key_submit",
770770
]
771771

772-
def _get_all_custom_code(self) -> dict[str, None]:
773-
"""Include the custom code for auto_height and enter_key_submit functionality.
772+
def add_custom_code(self) -> list[str]:
773+
"""Add custom Javascript code for auto_height and enter_key_submit.
774+
775+
Custom code is inserted at module level, after any imports. Each string
776+
is deduplicated per-page, so the same const or function is only
777+
included once even when multiple Textarea components are on the page.
774778
775779
Returns:
776-
The custom code for the component.
780+
The additional custom code for this component.
777781
"""
778-
custom_code = super()._get_all_custom_code()
782+
code: list[str] = []
779783
if self.auto_height is not None:
780-
custom_code[AUTO_HEIGHT_JS] = None
784+
code.append(AUTO_HEIGHT_JS)
781785
if self.enter_key_submit is not None:
782-
custom_code[ENTER_KEY_SUBMIT_JS] = None
783-
return custom_code
786+
code.append(ENTER_KEY_SUBMIT_JS)
787+
return code
784788

785789

786790
button = Button.create

0 commit comments

Comments
 (0)