Fix to truly move option tag rather than recreating

*Note: It keep existing styles and using index from "add()" will also put moved options to the top of the select and make them clearly visible
This commit is contained in:
Ilia Ross
2025-10-02 13:36:22 +03:00
parent b3ec083c7b
commit 8932f3bd6a

View File

@@ -1108,9 +1108,8 @@ if (dir == 1 && opts_idx >= 0) {
for(var i=0; i<opts.options.length; i++) {
var o = opts.options[i];
if (o.selected) {
vals.options[vals.options.length] =
new Option(o.text, o.value);
opts.remove(i);
o.selected = false;
vals.add(o, 0);
i--;
}
}
@@ -1120,9 +1119,8 @@ else if (dir == 0 && vals_idx >= 0) {
for(var i=0; i<vals.options.length; i++) {
var o = vals.options[i];
if (o.selected) {
opts.options[opts.options.length] =
new Option(o.text, o.value);
vals.remove(i);
o.selected = false;
opts.add(o, 0);
i--;
}
}