mirror of
https://gitlab.com/comunic/comunicconsole
synced 2024-12-25 13:08:52 +00:00
Can submit input by pressing enter
This commit is contained in:
parent
378808528e
commit
113c38daff
@ -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<HTMLFormElement>) {
|
||||
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<
|
||||
) : (
|
||||
<span></span>
|
||||
)}
|
||||
|
||||
<TextField
|
||||
label={this.state.inputOptions.label}
|
||||
variant="outlined"
|
||||
value={this.state.inputValue}
|
||||
onChange={this.handleInputValueChanged}
|
||||
type={this.state.inputOptions.type || "text"}
|
||||
/>
|
||||
<form onSubmit={this.submitInput}>
|
||||
<TextField
|
||||
label={this.state.inputOptions.label}
|
||||
variant="outlined"
|
||||
value={this.state.inputValue}
|
||||
onChange={this.handleInputValueChanged}
|
||||
type={this.state.inputOptions.type || "text"}
|
||||
/>
|
||||
</form>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={this.cancelInput} color="default">
|
||||
|
Loading…
Reference in New Issue
Block a user