Merge branch 'fix-input-field-error-not-shown' into uncategorised
This commit is contained in:
commit
e64f1c9ad7
|
@ -15,7 +15,8 @@ export default function EmailShare({ collection }) {
|
|||
|
||||
const collectionShare: SingleInputFormProps['callback'] = async (
|
||||
email,
|
||||
setFieldError
|
||||
setFieldError,
|
||||
resetForm
|
||||
) => {
|
||||
try {
|
||||
const user: User = getData(LS_KEYS.USER);
|
||||
|
@ -28,6 +29,7 @@ export default function EmailShare({ collection }) {
|
|||
} else {
|
||||
await shareCollection(collection, email);
|
||||
await galleryContext.syncWithRemote(false, true);
|
||||
resetForm();
|
||||
}
|
||||
} catch (e) {
|
||||
const errorMessage = handleSharingErrors(e);
|
||||
|
|
|
@ -400,28 +400,39 @@ function PhotoViewer(props: Iprops) {
|
|||
};
|
||||
|
||||
const updateItems = (items = []) => {
|
||||
if (photoSwipe) {
|
||||
if (items.length === 0) {
|
||||
photoSwipe.close();
|
||||
}
|
||||
photoSwipe.items.length = 0;
|
||||
items.forEach((item) => {
|
||||
photoSwipe.items.push(item);
|
||||
});
|
||||
photoSwipe.invalidateCurrItems();
|
||||
if (isOpen) {
|
||||
photoSwipe.updateSize(true);
|
||||
if (photoSwipe.getCurrentIndex() >= photoSwipe.items.length) {
|
||||
photoSwipe.goTo(0);
|
||||
try {
|
||||
if (photoSwipe) {
|
||||
if (items.length === 0) {
|
||||
photoSwipe.close();
|
||||
}
|
||||
photoSwipe.items.length = 0;
|
||||
items.forEach((item) => {
|
||||
photoSwipe.items.push(item);
|
||||
});
|
||||
|
||||
photoSwipe.invalidateCurrItems();
|
||||
if (isOpen) {
|
||||
photoSwipe.updateSize(true);
|
||||
if (
|
||||
photoSwipe.getCurrentIndex() >= photoSwipe.items.length
|
||||
) {
|
||||
photoSwipe.goTo(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
logError(e, 'updateItems failed');
|
||||
}
|
||||
};
|
||||
|
||||
const refreshPhotoswipe = () => {
|
||||
photoSwipe.invalidateCurrItems();
|
||||
if (isOpen) {
|
||||
photoSwipe.updateSize(true);
|
||||
try {
|
||||
photoSwipe.invalidateCurrItems();
|
||||
if (isOpen) {
|
||||
photoSwipe.updateSize(true);
|
||||
}
|
||||
} catch (e) {
|
||||
logError(e, 'refreshPhotoswipe failed');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import React, { useMemo, useState } from 'react';
|
||||
import constants from 'utils/strings/constants';
|
||||
import { Formik, FormikHelpers } from 'formik';
|
||||
import { Formik, FormikHelpers, FormikState } from 'formik';
|
||||
import * as Yup from 'yup';
|
||||
import SubmitButton from './SubmitButton';
|
||||
import TextField from '@mui/material/TextField';
|
||||
|
@ -14,7 +14,8 @@ interface formValues {
|
|||
export interface SingleInputFormProps {
|
||||
callback: (
|
||||
inputValue: string,
|
||||
setFieldError: (errorMessage: string) => void
|
||||
setFieldError: (errorMessage: string) => void,
|
||||
resetForm: (nextState?: Partial<FormikState<formValues>>) => void
|
||||
) => Promise<void>;
|
||||
fieldType: 'text' | 'email' | 'password';
|
||||
placeholder: string;
|
||||
|
@ -43,10 +44,11 @@ export default function SingleInputForm(props: SingleInputFormProps) {
|
|||
{ setFieldError, resetForm }: FormikHelpers<formValues>
|
||||
) => {
|
||||
SetLoading(true);
|
||||
await props.callback(values.inputValue, (message) =>
|
||||
setFieldError('inputValue', message)
|
||||
await props.callback(
|
||||
values.inputValue,
|
||||
(message) => setFieldError('inputValue', message),
|
||||
resetForm
|
||||
);
|
||||
resetForm();
|
||||
SetLoading(false);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue