Skip to content

Bug: click event is attached to createPortal #19611

@615349

Description

@615349

React version:
16.13.1

Steps To Reproduce

use createPortal will have click event attached to the DOM element automatically

import { createPortal } from "react-dom";

const Modal = ({ children, onClose, open }) =>
  open &&
  createPortal(
    <div />,
    document.getElementById("modal")
  );

this snippet will add click event attached to the element with id = modal
please open chrome dev tool to check

Link to code example:
https://codesandbox.io/s/vibrant-kowalevski-7ginb?file=/src/App.js

The current behavior

click event is added on the element

The expected behavior

click event should not be added

EDIT


createPortal(
    <h1>This is heading</h1>,
    document.getElementById("modal")
  );

The header is read by jaws (not sure about nvda) as
this is heading, heading level one, clickable

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions