Skip to content

Events propagate to nested components after stopPropagation() #1691

Closed
@lrowe

Description

@lrowe

We're using react-bootstrap modals in a site with full page rendering, so we have nested React rendering. As of d853c85 events are propagated to ancestors, but calls to event.stopPropagation() on the inner component hierarchy are not respected by the outer component hierarchy.

Complicating matters, the SyntheticEvent is created afresh for dispatch to each component hierarchy and there is no stoppedPropagation equivalent to nativeEvent.defaultPrevented to be called in the SyntheticEvent constructor. So even if forEachEventDispatch (EventPluginUtils.js) checked event.isPropagationStopped() in the single callback case, it would still return false.

Tracking the propagationStopped status through a return value of ReactEventEmitter.handleTopLevel looks tricky too given EventPluginHub.extractEvents may map a single nativeEvent to multiple synthetic events.

The easiest fix may just be to set a custom property on the nativeEvent object in SyntheticEvent.stopPropagation to check in the constructor, then check event.isPropagationStopped() in the single callback case of forEachEventDispatch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions