Skip to content

FIO-9944: Fixes an issue where some form instances will not be destroyed #610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
onNextPage?: (page: number, submission: Submission) => void;
onCancelSubmit?: () => void;
onCancelComponent?: (component: Component) => void;
onChange?: (value: any, flags: any, modified: boolean) => void;

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 62 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
onCustomEvent?: (event: {
type: string;
component: Component;
Expand All @@ -69,17 +69,17 @@
onComponentChange?: (changed: {
instance: Webform;
component: Component;
value: any;

Check warning on line 72 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 72 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 72 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type

Check warning on line 72 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 72 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 72 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
flags: any;

Check warning on line 73 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 73 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 73 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type

Check warning on line 73 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 73 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 73 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
}) => void;
onSubmit?: (submission: Submission, saved?: boolean) => void;
onSubmitDone?: (submission: Submission) => void;
onSubmitError?: (error: EventError) => void;
onFormLoad?: (form: JSON) => void;
onError?: (error: EventError | false) => void;
onRender?: (param: any) => void;

Check warning on line 80 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 80 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 80 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type

Check warning on line 80 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 80 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 80 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
onAttach?: (param: any) => void;

Check warning on line 81 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 81 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 81 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type

Check warning on line 81 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 81 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 81 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
onBuild?: (param: any) => void;

Check warning on line 82 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 82 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 82 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type

Check warning on line 82 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 82 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 82 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
onFocus?: (instance: Webform) => void;
onBlur?: (instance: Webform) => void;
onInitialized?: () => void;
Expand All @@ -91,7 +91,7 @@
onSubmissionDeleted?: (submission: Submission) => void;
onRequestDone?: () => void;
otherEvents?: {
[event: string]: (...args: any[]) => void;

Check warning on line 94 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 94 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 94 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type

Check warning on line 94 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 94 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 94 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
};
};

Expand All @@ -114,7 +114,7 @@
| 'formioform'
| 'Formio'
>,
...args: [string, ...any[]]

Check warning on line 117 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 117 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 117 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type

Check warning on line 117 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 117 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 117 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
) => {
const [event, ...outputArgs] = args;
if (event.startsWith('formio.')) {
Expand Down Expand Up @@ -319,7 +319,12 @@
if (formReadyCallback) {
formReadyCallback(instance);
}
setFormInstance(instance);
setFormInstance((prevInstance: any) => {
if (prevInstance) {
prevInstance.destroy(true);

Check warning on line 324 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 324 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / setup

Unexpected any. Specify a different type

Check warning on line 324 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / publish

Unexpected any. Specify a different type

Check warning on line 324 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 324 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type

Check warning on line 324 in src/components/Form.tsx

View workflow job for this annotation

GitHub Actions / sync-to-monorepo

Unexpected any. Specify a different type
}
return instance;
});
} else {
console.warn('Failed to create form instance');
}
Expand Down