Skip to content

Commit

Permalink
🐛 [open-formulieren/open-forms#3572] Fix potential race condition on …
Browse files Browse the repository at this point in the history
…WebKit

Backport-of: 585
  • Loading branch information
Viicos authored and sergei-maertens committed Nov 3, 2023
1 parent 9d7aaad commit 0f3462e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/FormStep/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ const FormStep = ({
*
* - `LOGIC_CHECK_INTERRUPTED` When there's no point/change in state to be expected by the logic
* check
* - `BLOCK_SUBMISSION` When the the logic is checking and the form should be disabled for
* - `BLOCK_SUBMISSION` When the logic is checking and the form should be disabled for
* submission.
* - `LOGIC_CHECK_DONE` When the logic check is done and the form should be enabled for
* submission.
Expand Down Expand Up @@ -710,7 +710,7 @@ const FormStep = ({
*
* During evaluation, the following actions are/may be dispatched:
*
* - `BLOCK_SUBMISSION` When the the form midfier by a humer (`modifiedByHuman`) and the form
* - `BLOCK_SUBMISSION` When the form was modified by a human (`modifiedByHuman`) and the form
* should be disabled for submission.
* - `ERROR` When an error occurred while evaluating the form logic.
* - `FORMIO_CHANGE_HANDLED` When the change is successfully handled .
Expand All @@ -726,6 +726,12 @@ const FormStep = ({
const onFormIOChange = async (changed, flags, modifiedByHuman) => {
// formio form not mounted -> nothing to do
if (!formRef.current) return;
// Under some conditions and engines (e.g. WebKit), `onFormIOChange` can be triggered while
// logicChecking is currently running (that is the scheduled logic check with `setTimeout` is ongoing).
// While it is running, `canSubmit` is set to `false` because of the fired `BLOCK_SUBMISSION` action.
// We don't want to get in conflict with the current check if the change doesn't come from the user.
// See https://github.com/open-formulieren/open-forms/issues/3572 for an example.
if (!modifiedByHuman && logicChecking) return;

// backend logic leads to changes in FormIO configuration, which triggers onFormIOInitialized.
// This in turn triggers the onFormIOChange event because the submission data is set
Expand Down

0 comments on commit 0f3462e

Please sign in to comment.