bind enter events as a submit to Popups
add s as key to submit a reshuffle in shuffled videos
This commit is contained in:
@ -2,13 +2,15 @@ import GlobalInfos from '../../utils/GlobalInfos';
|
||||
import style from './PopupBase.module.css';
|
||||
import {Line} from '../PageTitle/PageTitle';
|
||||
import React, {RefObject} from 'react';
|
||||
import {addKeyHandler, removeKeyHandler} from '../../utils/ShortkeyHandler';
|
||||
|
||||
interface props {
|
||||
width?: string;
|
||||
height?: string;
|
||||
banner?: JSX.Element;
|
||||
title: string;
|
||||
onHide: () => void
|
||||
onHide: () => void;
|
||||
ParentSubmit?: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -38,7 +40,7 @@ class PopupBase extends React.Component<props> {
|
||||
|
||||
componentDidMount(): void {
|
||||
document.addEventListener('mousedown', this.handleClickOutside);
|
||||
document.addEventListener('keyup', this.keypress);
|
||||
addKeyHandler(this.keypress);
|
||||
|
||||
// add element drag drop events
|
||||
if (this.wrapperRef != null) {
|
||||
@ -49,7 +51,7 @@ class PopupBase extends React.Component<props> {
|
||||
componentWillUnmount(): void {
|
||||
// remove the appended listeners
|
||||
document.removeEventListener('mousedown', this.handleClickOutside);
|
||||
document.removeEventListener('keyup', this.keypress);
|
||||
removeKeyHandler(this.keypress);
|
||||
}
|
||||
|
||||
render(): JSX.Element {
|
||||
@ -86,6 +88,9 @@ class PopupBase extends React.Component<props> {
|
||||
// hide if escape is pressed
|
||||
if (event.key === 'Escape') {
|
||||
this.props.onHide();
|
||||
} else if (event.key === 'Enter') {
|
||||
// call a parentsubmit if defined
|
||||
if (this.props.ParentSubmit) this.props.ParentSubmit();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user