Hi!
I have tried to use your modal window implementation, but encountered that
shouldCloseOnOverlayClick={false}
attribute actually does not work at all.
I've tried it several times, with values 'false' and with 'true' and in different browsers. In each case the modal dialog could be closed by clicking on the overlay area.
It seems that this attribute doesn't affect the Modal component behavior at all.
Please, fix it. Thanks.
@Diarsid Sorry for the trouble you are having. That prop is currently on our master branch, but we haven't cut a new release to npm yet. That will be happening shortly and then that prop will work to accomplish what you want.
Thanks one more time!
Version 1.0.0 has this and is now released.
Have the same issue now
react: 15.3.2
react-modal: 1.6.1
When I click on overlay, nothing happens
Same issue here. Neither escape key nor overlay click closures work.
react: 15.3.2
react-modal: 1.6.1
Okay, I did encounter this issue as well and turns out you MUST provide onRequestClose prop (a function that actually closes the modal) for shouldCloseOnOverlayClick to work. This info is given next to Testing in README and I guess others who've reported this issue (after v1.0.0) didn't notice it.
Seems like this problem has returned. Providing onRequestClose prop as well as setting shouldCloseOnOverlayClick to false. Clicking the overlay will not close the modal.
Tested this with
react-modal v2.2.2
Code sample
class App extends Component {
constructor(props) {
super(props);
this.state = {
modalIsOpen: true
};
}
closeModal = () => {
this.setState({ modalIsOpen: false });
};
render() {
return (
<div className="App">
<Modal isOpen={this.state.modalIsOpen} onRequestClose={this.closeModal}>
This is my modal
</Modal>
</div>
);
}
}
And it works just fine.
Tested this with react-modal v2.2.2.
shouldCloseOnOverlayClick is broken.
Code sample below:
<ReactModal
isOpen={this.state.showModal}
contentLabel="Foo"
shouldCloseOnOverlayClick={true}>
Hello
</ReactModal>
@donpinkus It does not work because it requires the onRequestClose prop to call. A prop which i added in my example.Not sure if it's mentioned somewhere, but shouldCloseOnOverlayClick depends on it.
@whitecrownclown That is correct. shouldCloseOnOverlayClick depends on onRequestClose because react-modal does not store the isOpen on its internal state.
@donpinkus @whitecrownclown If this detail is missing on the doc, can you please submit a PR?
Here is the link for our gitbook.
@whitecrownclown That is correct.
shouldCloseOnOverlayClickdepends ononRequestClosebecausereact-modaldoes not store theisOpenon its internal state.
I have a few comments regarding this behavior:
just my 2 cents
I just fixed this problem in a case where it wasn't working, even though I was supplying onRequestClose.
The problem was that I had some CSS that centered the content inside ReactModal. That CSS set the .ReactModal class to 100% width and height, which meant that the handleContentOnClick handler was being called, not handleOverlayOnClick.
Moving the CSS to the .ReactModal__Overlay class fixed the issue.
Most helpful comment
I have a few comments regarding this behavior:
just my 2 cents