Skip to content

Commit af08e06

Browse files
remove prop debounce_timeout from input and textarea (#1645)
1 parent d884b7b commit af08e06

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

reflex/components/forms/input.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ class Input(ChakraComponent):
5050
# "lg" | "md" | "sm" | "xs"
5151
size: Var[str]
5252

53-
# Time in milliseconds to wait between end of input and triggering on_change
54-
debounce_timeout: Var[int]
55-
5653
def _get_imports(self) -> imports.ImportDict:
5754
return imports.merge_imports(
5855
super()._get_imports(),
@@ -84,12 +81,14 @@ def create(cls, *children, **props) -> Component:
8481
Returns:
8582
The component.
8683
"""
87-
if isinstance(props.get("value"), Var) and props.get("on_change"):
84+
if (
85+
isinstance(props.get("value"), Var) and props.get("on_change")
86+
) or "debounce_timeout" in props:
87+
# Currently default to 50ms, which appears to be a good balance
88+
debounce_timeout = props.pop("debounce_timeout", 50)
8889
# create a debounced input if the user requests full control to avoid typing jank
8990
return DebounceInput.create(
90-
super().create(*children, **props),
91-
# Currently default to 50ms, which appears to be a good balance
92-
debounce_timeout=props.get("debounce_timeout", 50),
91+
super().create(*children, **props), debounce_timeout=debounce_timeout
9392
)
9493
return super().create(*children, **props)
9594

reflex/components/forms/textarea.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ class TextArea(ChakraComponent):
4343
# "outline" | "filled" | "flushed" | "unstyled"
4444
variant: Var[str]
4545

46-
# Time in milliseconds to wait between end of input and triggering on_change
47-
debounce_timeout: Var[int]
48-
4946
def get_controlled_triggers(self) -> Dict[str, Var]:
5047
"""Get the event triggers that pass the component's value to the handler.
5148
@@ -71,11 +68,13 @@ def create(cls, *children, **props) -> Component:
7168
Returns:
7269
The component.
7370
"""
74-
if isinstance(props.get("value"), Var) and props.get("on_change"):
71+
if (
72+
isinstance(props.get("value"), Var) and props.get("on_change")
73+
) or "debounce_timeout" in props:
74+
# Currently default to 50ms, which appears to be a good balance
75+
debounce_timeout = props.pop("debounce_timeout", 50)
7576
# create a debounced input if the user requests full control to avoid typing jank
7677
return DebounceInput.create(
77-
super().create(*children, **props),
78-
# Currently default to 50ms, which appears to be a good balance
79-
debounce_timeout=props.get("debounce_timeout", 50),
78+
super().create(*children, **props), debounce_timeout=debounce_timeout
8079
)
8180
return super().create(*children, **props)

0 commit comments

Comments
 (0)