From ed037fb2740418816b192abe06a250193ad05e40 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 --- 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 0673a50733..4e51a3b83f 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 ){ @@ -377,6 +378,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