From 7d547e5e11f142e0489f7b7b5d38cfb19a70dd81 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Thu, 29 Sep 2022 14:50:02 +0200 Subject: [PATCH] fix(linked_drop_down): in repetiton the second choice is saved the filter was not applied in repetition block so an additional empty input was send which overrided the real value --- app/javascript/controllers/autosave_controller.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/javascript/controllers/autosave_controller.ts b/app/javascript/controllers/autosave_controller.ts index 6f786c219..daded6e18 100644 --- a/app/javascript/controllers/autosave_controller.ts +++ b/app/javascript/controllers/autosave_controller.ts @@ -193,11 +193,13 @@ export class AutosaveController extends ApplicationController { private get inputs() { const element = this.element as HTMLElement; + const inputs = [ ...element.querySelectorAll( 'input:not([type=file]), textarea, select' ) - ]; + ].filter((element) => !element.disabled); + const parent = this.element.closest('.editable-champ-repetition'); if (parent) { return [ @@ -205,6 +207,6 @@ export class AutosaveController extends ApplicationController { ...parent.querySelectorAll('input[data-id]') ]; } - return inputs.filter((element) => !element.disabled); + return inputs; } }