From 113c38daff67f59cfb67e40108c101bba5bd9b20 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Tue, 13 Jul 2021 17:14:54 +0200 Subject: [PATCH] Can submit input by pressing enter --- src/ui/widgets/DialogsProvider.tsx | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/ui/widgets/DialogsProvider.tsx b/src/ui/widgets/DialogsProvider.tsx index f036469..a45b95a 100644 --- a/src/ui/widgets/DialogsProvider.tsx +++ b/src/ui/widgets/DialogsProvider.tsx @@ -16,7 +16,7 @@ import { IconButton, } from "@material-ui/core"; import { Close } from "@material-ui/icons"; -import React from "react"; +import React, { FormEvent } from "react"; let cache: ApplicationDialogsProvider; @@ -94,6 +94,7 @@ export class ApplicationDialogsProvider extends React.Component< this.acceptConfirm = this.handleCloseConfirm.bind(this, true); this.rejectConfirm = this.handleCloseConfirm.bind(this, false); + this.submitInput = this.submitInput.bind(this); this.handleInputValueChanged = this.handleInputValueChanged.bind(this); this.cancelInput = this.handleCloseInput.bind(this, true); this.confirmInput = this.handleCloseInput.bind(this, false); @@ -158,7 +159,14 @@ export class ApplicationDialogsProvider extends React.Component< this.setState({ inputValue: e.target.value }); } + submitInput(e: FormEvent) { + e.preventDefault(); + this.handleCloseInput(false); + } + handleCloseInput(cancel: boolean) { + if (!cancel && !this.isInputValid) return; + this.setState({ showInputDialog: false, }); @@ -286,14 +294,15 @@ export class ApplicationDialogsProvider extends React.Component< ) : ( )} - - +
+ +