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 <kyle@bywatersolutions.com>
Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit ed037fb274)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Thibaud Guillot 2024-02-23 13:12:42 +01:00 committed by Fridolin Somers
parent a42bce58b2
commit 4d7df951f3

View file

@ -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;
}