fix: [settings] Correctly detect value changes for select[multiple]
parent
6c4efc044d
commit
64fdd4d290
|
@ -52,6 +52,9 @@ $(document).ready(function () {
|
|||
oldValue = oldValue !== undefined ? oldValue : ''
|
||||
}
|
||||
$input.val(oldValue)
|
||||
if ($input.is('select') && $input.prop('multiple')) {
|
||||
$input.trigger('change')
|
||||
}
|
||||
handleSettingValueChange($input)
|
||||
})
|
||||
|
||||
|
@ -85,7 +88,11 @@ function handleSettingValueChange($input) {
|
|||
if ($input.attr('type') == 'checkbox') {
|
||||
oldValue = oldValue == true
|
||||
}
|
||||
if (newValue == oldValue || (newValue == '' && oldValue == undefined)) {
|
||||
let hasChanged = newValue != oldValue
|
||||
if ($input.is('select') && $input.prop('multiple')) {
|
||||
hasChanged = !arrayEqual(oldValue, newValue)
|
||||
}
|
||||
if (!hasChanged || (newValue == '' && oldValue == undefined)) {
|
||||
restoreWarnings($input)
|
||||
} else {
|
||||
removeWarnings($input)
|
||||
|
|
|
@ -145,4 +145,10 @@ function debounce(func, wait, options) {
|
|||
debounced.flush = flush
|
||||
debounced.pending = pending
|
||||
return debounced
|
||||
}
|
||||
|
||||
function arrayEqual(array1, array2) {
|
||||
const array2Sorted = array2.slice().sort();
|
||||
return array1.length === array2.length && array1.slice().sort().every((value, index) => value === array2Sorted[index])
|
||||
|
||||
}
|
Loading…
Reference in New Issue