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.
This commit is contained in:
Masen Furer 2024-10-28 16:59:26 -07:00 committed by GitHub
parent 41b1958626
commit 8f07082eba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -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:

View File

@ -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]