submit action - run with enter

This commit is contained in:
Jan Prochazka
2020-12-05 16:52:57 +01:00
parent a3837083da
commit 10dc7343ae
6 changed files with 57 additions and 20 deletions

View File

@@ -12,10 +12,19 @@ export default function ChangeDownloadUrlModal({ modalState, url = '', onConfirm
// React.useEffect(() => {
// if (textFieldRef.current) textFieldRef.current.focus();
// }, [textFieldRef.current]);
const handleSubmit = async (values) => {
onConfirm(values.url);
modalState.close();
};
// const handleSubmit = () => async (values) => {
// onConfirm(values.url);
// modalState.close();
// };
const handleSubmit = React.useCallback(
async (values) => {
onConfirm(values.url);
modalState.close();
},
[modalState, onConfirm]
);
return (
<ModalBase modalState={modalState}>
<ModalHeader modalState={modalState}>Download imported file from web</ModalHeader>

View File

@@ -3,22 +3,26 @@ import ModalBase from './ModalBase';
import FormStyledButton from '../widgets/FormStyledButton';
import ModalFooter from './ModalFooter';
import ModalContent from './ModalContent';
import { FormSubmit } from '../utility/forms';
import { FormProvider } from '../utility/FormProvider';
export default function ConfirmModal({ message, modalState, onConfirm }) {
return (
<ModalBase modalState={modalState}>
<ModalContent>{message}</ModalContent>
<FormProvider>
<ModalBase modalState={modalState}>
<ModalContent>{message}</ModalContent>
<ModalFooter>
<FormStyledButton
value="OK"
onClick={() => {
modalState.close();
onConfirm();
}}
/>
<FormStyledButton type="button" value="Close" onClick={modalState.close} />
</ModalFooter>
</ModalBase>
<ModalFooter>
<FormSubmit
value="OK"
onClick={() => {
modalState.close();
onConfirm();
}}
/>
<FormStyledButton type="button" value="Close" onClick={modalState.close} />
</ModalFooter>
</ModalBase>
</FormProvider>
);
}

View File

@@ -70,6 +70,7 @@ export default function ModalBase({ modalState, children, isFlex = false, fullSc
overlayClassName="RactModalOverlay"
fullScreen={fullScreen}
isFlex={isFlex}
ariaHideApp={false}
// style={{
// overlay: {
// backgroundColor: '#000',