fix(web): move input dialog enter handler

it was causing issues where when confirming a selection in the list menu it would instantly close the input dialog
This commit is contained in:
Luke
2022-08-26 18:49:49 +02:00
parent 3db5ccc86d
commit ae25d109fc

View File

@@ -61,13 +61,8 @@ 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,
@@ -110,7 +105,11 @@ const InputDialog: React.FC = () => {
size="xs"
>
<ModalOverlay />
<ModalContent>
<ModalContent
onKeyDown={(e) => {
if (e.key === 'Enter' && visible) return handleConfirm();
}}
>
<ModalHeader textAlign="center">{fields.heading}</ModalHeader>
<ModalBody fontFamily="Poppins" textAlign="left">
{fields.rows.map((row: IInput | ICheckbox | ISelect | INumber | ISlider, index) => (