From 7460d3a0bc3ccf06b36074165782bfc08cc25e36 Mon Sep 17 00:00:00 2001 From: Viktor Fomin Date: Fri, 29 Apr 2022 12:19:12 +0300 Subject: [PATCH] Web: Files: EmptyTrashDoalog: fix style, delete on enter --- .../dialogs/EmptyTrashDialog/index.js | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/products/ASC.Files/Client/src/components/dialogs/EmptyTrashDialog/index.js b/products/ASC.Files/Client/src/components/dialogs/EmptyTrashDialog/index.js index 7b44f9b0e1..f639dd660d 100644 --- a/products/ASC.Files/Client/src/components/dialogs/EmptyTrashDialog/index.js +++ b/products/ASC.Files/Client/src/components/dialogs/EmptyTrashDialog/index.js @@ -1,4 +1,5 @@ -import React from "react"; +import React, { useEffect } from "react"; +import styled from "styled-components"; import { withRouter } from "react-router"; import ModalDialogContainer from "../ModalDialogContainer"; import Text from "@appserver/components/text"; @@ -7,6 +8,10 @@ import ModalDialog from "@appserver/components/modal-dialog"; import { withTranslation } from "react-i18next"; import { inject, observer } from "mobx-react"; +const StyledModal = styled(ModalDialogContainer)` + max-width: 400px; +`; + const EmptyTrashDialogComponent = (props) => { const { visible, @@ -17,6 +22,12 @@ const EmptyTrashDialogComponent = (props) => { emptyTrash, } = props; + useEffect(() => { + window.addEventListener("keydown", onKeyPress); + + return () => window.removeEventListener("keydown", onKeyPress); + }, []); + const onClose = () => setEmptyTrashDialogVisible(false); const onEmptyTrash = () => { @@ -28,12 +39,14 @@ const EmptyTrashDialogComponent = (props) => { emptyTrash(translations); }; + const onKeyPress = (e) => { + if (e.keyCode === 13) { + onEmptyTrash(); + } + }; + return ( - + {t("DeleteForeverTitle")} {t("DeleteForeverNote")} @@ -56,7 +69,7 @@ const EmptyTrashDialogComponent = (props) => { isLoading={isLoading} /> - + ); };