feat(web/input): submit on enter press

This commit is contained in:
Luke
2022-06-19 15:13:43 +02:00
parent 5183607279
commit a3b8154b3e
2 changed files with 41 additions and 1 deletions

View File

@@ -17,6 +17,7 @@ import InputNumber from "./components/number";
import Input from "./components/input";
import CheckboxField from "./components/checkbox";
import SelectField from "./components/select";
import { useKeyPress } from "../../hooks/useKeyPress";
interface Props {
heading: string;
@@ -58,9 +59,13 @@ const InputDialog: React.FC = () => {
>([]);
const [passwordStates, setPasswordStates] = React.useState<boolean[]>([]);
const [visible, setVisible] = React.useState(false);
const enterPressed = useKeyPress("Enter");
const { locale } = useLocales();
React.useEffect(() => {
if (visible && enterPressed === false) handleConfirm();
}, [enterPressed]);
const handlePasswordStates = (index: number) => {
setPasswordStates({
...passwordStates,