From 1a66fa3bc3b1cda7d4711d4e6062c9a2e16c1224 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Tue, 10 Nov 2026 11:06:00 +0100 Subject: [PATCH] fix(editor): save all extra settings changed in quick succession The extra settings of a question are saved debounced, but only the change of the last call within the debounce time was saved, merged into the settings from before the first one. Switching on "Shuffle options" and "Add other" quickly saved only "Add other". The changes are now collected and saved together. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Andy Scherzinger --- src/composables/useQuestion.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/composables/useQuestion.ts b/src/composables/useQuestion.ts index c7a140bf1..e82281264 100644 --- a/src/composables/useQuestion.ts +++ b/src/composables/useQuestion.ts @@ -209,14 +209,24 @@ export function useQuestion(props: QuestionPropsLike, options: UseQuestionOption saveQuestionProperty('isRequired', isRequiredValue) }, INPUT_DEBOUNCE_MS) - const onExtraSettingsChange = debounce(function ( - newSettings: Record, - ) { - const newExtraSettings = { ...props.extraSettings, ...newSettings } + let pendingExtraSettings: Record = {} + const saveExtraSettings = debounce(function () { + const newExtraSettings = { ...props.extraSettings, ...pendingExtraSettings } + pendingExtraSettings = {} options.emit('update:extraSettings', newExtraSettings) saveQuestionProperty('extraSettings', newExtraSettings) }, INPUT_DEBOUNCE_MS) + /** + * Save changed extra settings; changes within the debounce time are saved together + * + * @param newSettings the changed extra settings + */ + const onExtraSettingsChange = (newSettings: Record): void => { + pendingExtraSettings = { ...pendingExtraSettings, ...newSettings } + saveExtraSettings() + } + const onNameChange = debounce(function (name: string) { options.emit('update:name', name) saveQuestionProperty('name', name)