Skip to content

Commit

Permalink
Handle props annotated as list/dict of EventHandler (#4257)
Browse files Browse the repository at this point in the history
These props are NOT event triggers themselves, but rather they are props that
expect a list or dict of event handlers.

Additional fix for calling an `@rx.event` decorated event handler with no
arguments.
  • Loading branch information
masenf authored Oct 28, 2024
1 parent 41b1958 commit 8f07082
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion reflex/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ def get_event_triggers(self) -> Dict[str, Any]:
# Look for component specific triggers,
# e.g. variable declared as EventHandler types.
for field in self.get_fields().values():
if types._issubclass(field.type_, EventHandler):
if types._issubclass(field.outer_type_, EventHandler):
args_spec = None
annotation = field.annotation
if (metadata := getattr(annotation, "__metadata__", None)) is not None:
Expand Down
5 changes: 5 additions & 0 deletions reflex/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,11 @@ def stop_propagation(self):
"""
return self

@overload
def __call__(
self: EventCallback[Q, T],
) -> EventCallback[Q, T]: ...

@overload
def __call__(
self: EventCallback[Concatenate[V, Q], T], value: V | Var[V]
Expand Down

0 comments on commit 8f07082

Please sign in to comment.