bootstrap-duallistbox icon indicating copy to clipboard operation
bootstrap-duallistbox copied to clipboard

Can not moveOnSelect, a selected item.

Open lestcape opened this issue 7 years ago • 1 comments

The option moveOnSelect cannot move a selected item (at it is already) and eventually one item will be selected.

Steep to reproduce: 1- Filter the select1 (left). 2- Select one item in the select1(left) and it will appeared selected in the select2(right).

Once it happen, the current selected item can not be selected again, so can not be moved to the left list again on a selection in the right list.

Workaround: Also capture the click instead of only the change in this lines:

https://github.com/istvan-ujjmeszaros/bootstrap-duallistbox/blob/v4/dist/jquery.bootstrap-duallistbox.js#L566 https://github.com/istvan-ujjmeszaros/bootstrap-duallistbox/blob/v4/dist/jquery.bootstrap-duallistbox.js#L569

this.elements.select1.on('change', function() {
this.elements.select2.on('change', function() {

It will be:

this.elements.select1.on('click change', function() {
this.elements.select2.on('click change', function() {

lestcape avatar Apr 16 '19 05:04 lestcape

I think a good fix is here: https://github.com/istvan-ujjmeszaros/bootstrap-duallistbox/blob/v4/dist/jquery.bootstrap-duallistbox.js#L162 https://github.com/istvan-ujjmeszaros/bootstrap-duallistbox/blob/v4/dist/jquery.bootstrap-duallistbox.js#L164

dualListbox.elements.select2.append($item.clone(true).prop('selected', !(dualListbox.settings.moveOnSelect) && $item.data('_selected')));
dualListbox.elements.select1.append($item.clone(true).prop('selected', !(dualListbox.settings.moveOnSelect) && $item.data('_selected')));

Instead of

dualListbox.elements.select2.append($item.clone(true).prop('selected', $item.data('_selected')));
dualListbox.elements.select1.append($item.clone(true).prop('selected', $item.data('_selected')));

lestcape avatar Apr 16 '19 06:04 lestcape