Browse Source

Handle props annotated as list/dict of EventHandler (#4257)

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.
Masen Furer 6 months ago
parent
commit
5a5be8162b
2 changed files with 6 additions and 1 deletions
  1. 1 1
      reflex/components/component.py
  2. 5 0
      reflex/event.py

+ 1 - 1
reflex/components/component.py

@@ -645,7 +645,7 @@ class Component(BaseComponent, ABC):
         # 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:

+ 5 - 0
reflex/event.py

@@ -1489,6 +1489,11 @@ if sys.version_info >= (3, 10):
             """
             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]