Skip to content

Closing the modal when overlay is clicked not working #213

@emwee

Description

@emwee

Hi, I am using the react-modal component but noticed the modal itself does not close when I click outside the modal (i.e. on the overlay)

Some example code:

<Modal
    isOpen={this.state.modalIsOpen}
    overlayClassName='modal-overlay'
    className='modal-overlay-content'
>
    <p>Contents...</p>
</Modal>

SASS code:

.modal-overlay
    +mask()
    +opacity(1)
    color: color(grey1)
    width: 100%
    height: 100%
    background-color: rgba(color(black), 0.24)
    +flexbox()
    +align-items(center)
    +justify-content(center)

.modal-overlay-content
    margin: 0.5rem
    padding: 1rem
    outline: none
    overflow: auto
    background-color: color(white)
    +box-shadow(0 10px 20px 0 rgba(0, 0, 0, 0.24), 0 16px 40px 0 rgba(0, 0, 0, 0.32))
    +border-radius()

I am using version 1.4.0.

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