Skip to content

Add support for appending modal node to non-root nodes #23

@ajclaasen

Description

@ajclaasen

Heya, thanks for this package, it's saved me & my team quite a bit of time already & it works great!

I am running into an issue when testing components that use the modals from this package. Because this package appends modals to the document root, and not to the element calling the render, it is causing them to persist between tests.

I am using react-testing-library, which, as part of its optimalisations, does not rerender the entire document between specs, but only rerenders the component being tested1.

Looking at the source code of react-confirm, it seems that it should not be too hard to add support for appending the modal elsewhere2 by passing the node to be appended to to the createConfirmation method.

Footnotes

  1. https://github.com/testing-library/react-testing-library/blob/ccd8a0d97dd9da0a420f2cf012a24d414d1646ed/src/pure.js#L208

  2. https://github.com/haradakunihiko/react-confirm/blob/3f6a23c353338f7e0302b6e6c5e53c8d46c3e899/src/createConfirmation.js#L4-L6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions