Skip to content

Commit f3c6d6d

Browse files
committed
After prevented removing of item in multiselect, proper item is focused
1 parent 86a9c79 commit f3c6d6d

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

select2.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2610,13 +2610,15 @@ the specific language governing permissions and limitations under the Apache Lic
26102610
selectedChoice = next.length ? next : null;
26112611
}
26122612
else if (e.which === KEY.BACKSPACE) {
2613-
this.unselect(selected.first());
2614-
this.search.width(10);
2615-
selectedChoice = prev.length ? prev : next;
2613+
if (this.unselect(selected.first())) {
2614+
this.search.width(10);
2615+
selectedChoice = prev.length ? prev : next;
2616+
}
26162617
} else if (e.which == KEY.DELETE) {
2617-
this.unselect(selected.first());
2618-
this.search.width(10);
2619-
selectedChoice = next.length ? next : null;
2618+
if (this.unselect(selected.first())) {
2619+
this.search.width(10);
2620+
selectedChoice = next.length ? next : null;
2621+
}
26202622
} else if (e.which == KEY.ENTER) {
26212623
selectedChoice = null;
26222624
}
@@ -2992,7 +2994,7 @@ the specific language governing permissions and limitations under the Apache Lic
29922994
this.opts.element.trigger(evt);
29932995

29942996
if (evt.isDefaultPrevented()) {
2995-
return;
2997+
return false;
29962998
}
29972999

29983000
while((index = indexOf(this.id(data), val)) >= 0) {
@@ -3005,6 +3007,8 @@ the specific language governing permissions and limitations under the Apache Lic
30053007

30063008
this.opts.element.trigger({ type: "select2-removed", val: this.id(data), choice: data });
30073009
this.triggerChange({ removed: data });
3010+
3011+
return true;
30083012
},
30093013

30103014
// multi

0 commit comments

Comments
 (0)