diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ddc05ab..5ba5db8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ before starting to add changes. Use example [placed in the end of the page](#exa ## [Unreleased] +- [337](https://github.com/OS2Forms/os2forms/pull/337) + Avoid inheriting data on page transition in MaestroWebformInheritTask. + ## [5.1.0] 2026-06-03 - [PR-326](https://github.com/OS2Forms/os2forms/pull/326) diff --git a/modules/os2forms_forloeb/src/Plugin/EngineTasks/MaestroWebformInheritTask.php b/modules/os2forms_forloeb/src/Plugin/EngineTasks/MaestroWebformInheritTask.php index 9544cee5..dd25f1cd 100644 --- a/modules/os2forms_forloeb/src/Plugin/EngineTasks/MaestroWebformInheritTask.php +++ b/modules/os2forms_forloeb/src/Plugin/EngineTasks/MaestroWebformInheritTask.php @@ -144,6 +144,13 @@ public function prepareTaskForSave(array &$form, FormStateInterface $form_state, * Implements hook_webform_submission_form_alter(). */ public static function webformSubmissionFormAlter(array &$form, FormStateInterface $formState, string $formId) { + // Only inherit values on the initial form load. This skip condition is the + // complement of webform's own prepopulate guard. + // @see \Drupal\webform\WebformSubmissionForm::buildForm() + if ($formState->isRebuilding() && !$formState->get('is_ajax_restart')) { + return; + } + // @todo Clean up and align with MaestroHelper::maestroZeroUserNotification(). if ($queueID = self::getQueueIdFromRequest()) { $templateTask = MaestroEngine::getTemplateTaskByQueueID($queueID);