From 5bfa03865205a8dc086a3d9d763605cfb3aa87ac Mon Sep 17 00:00:00 2001 From: Thibaud Guillot Date: Fri, 23 Feb 2024 13:12:42 +0100 Subject: [PATCH] Bug 36156: None value selected on clone field/subfield linked to AV When a field or subfield is linked to a list of authorized values and cloned, the selected value is repeated in the clone. This is linked to the default behavior of Select2Utils, so I've added a precise index (-1) to ensure that no value is selected in the clone. Test plan: 1) Create a repeatable field and subfield and link a list of authorised values to the subfield. 2) Edit a record, clone the field and see which value is automatically selected in the clone. 3) Apply the patch 4) Repeat step 2 Sponsored by : BibLibre Signed-off-by: Kyle M Hall Signed-off-by: Pedro Amorim Signed-off-by: Katrin Fischer (cherry picked from commit ed037fb2740418816b192abe06a250193ad05e40) Signed-off-by: Fridolin Somers (cherry picked from commit 4d7df951f3572ca7063f5bbd869618b29e6e8607) Signed-off-by: Lucas Gass --- koha-tmpl/intranet-tmpl/prog/js/cataloging.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js index 8808df2c71..e3f9a7446c 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/cataloging.js +++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging.js @@ -218,6 +218,7 @@ function CloneField(index, hideMarc, advancedMARCEditor) { id_input = selects[0].getAttribute('id')+new_key; selects[0].setAttribute('id',id_input); selects[0].setAttribute('name',selects[0].getAttribute('name')+new_key); + selects[0].selectedIndex = -1; }catch(e2){ // it is a textarea if it s not a select or an input var textareas = divs[i].getElementsByTagName('textarea'); if( textareas.length > 0 ){ @@ -371,6 +372,7 @@ function CloneSubfield(index, advancedMARCEditor){ id_input = selects[i].getAttribute('id')+new_key; selects[i].setAttribute('id',selects[i].getAttribute('id')+new_key); selects[i].setAttribute('name',selects[i].getAttribute('name')+new_key); + selects[i].selectedIndex = -1; linkid = id_input; } -- 2.20.1