Skip to content

Conversation

@benedikt-bartscher
Copy link
Contributor

No description provided.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 24, 2026

Merging this PR will not alter performance

✅ 8 untouched benchmarks


Comparing benedikt-bartscher:fix-mixin-event-actions (b11f75f) with main (be43052)

Open in CodSpeed

@benedikt-bartscher benedikt-bartscher marked this pull request as ready for review January 24, 2026 21:22
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 24, 2026

Greptile Overview

Greptile Summary

Fixed a bug where event_actions (such as prevent_default and stop_propagation) from the @rx.event decorator were lost when event handlers were inherited from mixin classes. The fix mirrors the existing pattern used for preserving the BACKGROUND_TASK_MARKER attribute.

  • Added preservation of _rx_event_actions attribute in the _copy_fn method
  • Added test case to verify event_actions are properly preserved through mixin inheritance
  • Follows existing code patterns for attribute preservation during function copying

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix is well-targeted and follows the existing pattern for preserving function attributes (mirrors BACKGROUND_TASK_MARKER preservation). The change is minimal, includes a comprehensive test case, and addresses a specific bug without introducing side effects.
  • No files require special attention

Important Files Changed

Filename Overview
reflex/state.py Preserves _rx_event_actions attribute when copying event handler functions from mixins
tests/units/test_state.py Adds test verifying event_actions are preserved when event handlers are inherited from mixins

Sequence Diagram

sequenceDiagram
    participant Decorator as @rx.event decorator
    participant MixinClass as EventActionsMixin
    participant CopyFn as _copy_fn method
    participant ChildClass as UsesEventActionsMixin
    participant CreateHandler as _create_event_handler

    Note over Decorator,MixinClass: Mixin Definition
    Decorator->>MixinClass: Decorate handle_with_actions()
    Decorator->>MixinClass: Set _rx_event_actions attribute
    
    Note over ChildClass: Child Class Inherits Mixin
    ChildClass->>CopyFn: Copy event handler from mixin
    CopyFn->>CopyFn: Create new FunctionType
    CopyFn->>CopyFn: Copy annotations
    CopyFn->>CopyFn: Preserve BACKGROUND_TASK_MARKER
    CopyFn->>CopyFn: Preserve _rx_event_actions (NEW)
    CopyFn->>ChildClass: Return copied function
    
    Note over CreateHandler: Event Handler Creation
    ChildClass->>CreateHandler: Create event handler
    CreateHandler->>CreateHandler: Get _rx_event_actions from fn
    CreateHandler->>ChildClass: Return EventHandler with event_actions
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant