Browser scroll does not reset
Steps to reproduce:
- Open a modal dialog with bunch of data (enough data to get scroll in browser)
- scroll browser to bottom
- click outside of popup
- once again open popup
- popup opens up with scrolling at bottom and header is not visible
The Same thing can be viewed in demo page (http://minhtranite.github.io/react-modal-bootstrap/) with smaller browser height.
Can we change anything to make sure everytime modal dialog is opened, it should scroll to the top and the modal header is visible at first.
I think the problem is that the content of the modal is not re-rendered, just hidden. I have the same problem with some checkboxs.. after the modal is closed, opened a second time the values selected are still there. Any idea on how to force to render again on open?
Right now whenever my modal closes, it scrolls all the way left and does not return to the original div that called it. Ive tried every api callback and every react lifecycle method, and nothing works. However, if i use scrollIntoView in the terminal, it works just fine.
Steps to Reproduce:
- Go to http://www.arabisraeliconflictmadesimple.com/timeline
- press options, UN
- scroll right to 1967
- press on "UN security resolution 242"
- Notice that we are back to 1947
Here's my component that calls the modals
import React, {Component} from 'react'
import $ from 'jquery'
import Modal from 'react-responsive-modal'
class InfoSquare extends Component {
constructor(props) {
super(props)
this.state = {
open: false,
};
}
onOpenModal() {
if (this.props.modal_info)
this.setState({ open: true });
}
scrollBack() {
let to_return = document.getElementById(`${this.props.year}`)
to_return.scrollIntoView();
}
onCloseModal() {
this.setState({ open: false });
}
render(props) {
const { open } = this.state;
return (
<div>
<p className={`${this.props.indicator}-text`} onClick={this.onOpenModal.bind(this)} >{this.props.text}</p>
<Modal open={open} onClose={this.onCloseModal.bind(this)} onAfterOpen={this.scrollBack} little>
<h4>{this.props.text}</h4>
{this.props.modal_info &&
this.props.modal_info.map(info => <p key={info}>{info}</p>)
}
</Modal>
</div>
);
}
}
export default InfoSquare;