Skip to content
Snippets Groups Projects
Commit d1998069 authored by ThibG's avatar ThibG Committed by Eugen Rochko
Browse files

Prevent scrolling main frame when navigating in image gallery with arrow keys (#8073)

parent c9739ca8
No related branches found
No related tags found
No related merge requests found
......@@ -54,19 +54,23 @@ export default class MediaModal extends ImmutablePureComponent {
this.setState({ index: index % this.props.media.size });
}
handleKeyUp = (e) => {
handleKeyDown = (e) => {
switch(e.key) {
case 'ArrowLeft':
this.handlePrevClick();
e.preventDefault();
e.stopPropagation();
break;
case 'ArrowRight':
this.handleNextClick();
e.preventDefault();
e.stopPropagation();
break;
}
}
componentDidMount () {
window.addEventListener('keyup', this.handleKeyUp, false);
window.addEventListener('keydown', this.handleKeyDown, false);
if (this.context.router) {
const history = this.context.router.history;
history.push(history.location.pathname, previewState);
......@@ -77,7 +81,7 @@ export default class MediaModal extends ImmutablePureComponent {
}
componentWillUnmount () {
window.removeEventListener('keyup', this.handleKeyUp);
window.removeEventListener('keydown', this.handleKeyDown);
if (this.context.router) {
this.unlistenHistory();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment