Skip to content

Overlay Mask child element onClick event bubble up #3429

@TAYTS

Description

@TAYTS

Hi, may I know is it possible to add a check on the event target for the OverlayMask component to prevent onClick getting triggered by the bubbling up of the child element's click event?

The use case is that I was trying to allow both the EuiOverlayMask and EuiModal's close button to close the modal. However, when I tried to submit the modal form, the EuiOverlayMask's onClick got triggered by the bubbling of the click event from the modal submit button.

if (onClick) {
this.overlayMaskNode.addEventListener('click', onClick);
}

Suggestion:

if (onClick) { 
  this.overlayMaskNode.addEventListener('click', (e) => {
    if (this == e.target) {
      onClick();
    }
  }); 
} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions