Skip to content

when bodyOpenClassName is null, ModalPortal:componentWillUnmount fails #697

Open
@benjiwheeler

Description

@benjiwheeler

Summary:

ReactModal does not correctly handle case when bodyOpenClassName is null

Steps to reproduce:

  1. render a with prop bodyOpenClassName={null}
  2. cause it to no longer render, forcing it to unmount
  3. see console error, in ModalPortal:afterClose() -> classList.js:remove(): Uncaught TypeError: Cannot read property 'split' of null

Example:

https://codepen.io/benjiwheeler/pen/aRJzOY?editors=1111

To see the problem in this Codepen:

  1. open browser js console
  2. after codepen execution pane reloads, click "Trigger the modal"
  3. see the console error
  4. clear the console output
  5. remove the bodyOpenClassName={null} from the js code on the top right
  6. after codepen execution pane reloads, click "Trigger the modal"
  7. observe that there is no error and the modal is fine!

Expected behavior:

ReactModal should either strictly require a non-null bodyOpenClassName, or render without applying any bodyOpenClassName. It should not assume a non-null bodyOpenClassName exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions