Automatically open search when typing
This fixes an issue where the dropdown would not automatically open when something was typed in the search box on a multiple select. This was most noticeable when the dropdown closed and the search box was focused and the user started to type, as the text would appear in the search box, queries would be sent out to retrieve results, but the dropdown would not be opened to display the results. This also fixes an issue introduced in a recent commit where search queries would be sent out twice on modern browsers that supported both the `keyup` and `input` event. The `keyup` event is now properly debounced for these browsers and the queries are only going out once. This closes https://github.com/select2/select2/issues/3036.
This commit is contained in:
parent
017c201094
commit
94875679f8
8
dist/js/select2.amd.full.js
vendored
8
dist/js/select2.amd.full.js
vendored
@ -1318,10 +1318,10 @@ define('select2/selection/search',[
|
|||||||
// both the `keyup` and `input` events.
|
// both the `keyup` and `input` events.
|
||||||
this.$selection.on('input', '.select2-search--inline', function (evt) {
|
this.$selection.on('input', '.select2-search--inline', function (evt) {
|
||||||
// Unbind the duplicated `keyup` event
|
// Unbind the duplicated `keyup` event
|
||||||
$(this).off('keyup');
|
self.$selection.off('keyup.search');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$selection.on('keyup input', '.select2-search--inline',
|
this.$selection.on('keyup.search input', '.select2-search--inline',
|
||||||
function (evt) {
|
function (evt) {
|
||||||
self.handleSearch(evt);
|
self.handleSearch(evt);
|
||||||
});
|
});
|
||||||
@ -4471,6 +4471,10 @@ define('select2/core',[
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.on('query', function (params) {
|
this.on('query', function (params) {
|
||||||
|
if (!self.isOpen()) {
|
||||||
|
self.trigger('open');
|
||||||
|
}
|
||||||
|
|
||||||
this.data.query(params, function (data) {
|
this.data.query(params, function (data) {
|
||||||
self.trigger('results:all', {
|
self.trigger('results:all', {
|
||||||
data: data,
|
data: data,
|
||||||
|
8
dist/js/select2.amd.js
vendored
8
dist/js/select2.amd.js
vendored
@ -1318,10 +1318,10 @@ define('select2/selection/search',[
|
|||||||
// both the `keyup` and `input` events.
|
// both the `keyup` and `input` events.
|
||||||
this.$selection.on('input', '.select2-search--inline', function (evt) {
|
this.$selection.on('input', '.select2-search--inline', function (evt) {
|
||||||
// Unbind the duplicated `keyup` event
|
// Unbind the duplicated `keyup` event
|
||||||
$(this).off('keyup');
|
self.$selection.off('keyup.search');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$selection.on('keyup input', '.select2-search--inline',
|
this.$selection.on('keyup.search input', '.select2-search--inline',
|
||||||
function (evt) {
|
function (evt) {
|
||||||
self.handleSearch(evt);
|
self.handleSearch(evt);
|
||||||
});
|
});
|
||||||
@ -4471,6 +4471,10 @@ define('select2/core',[
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.on('query', function (params) {
|
this.on('query', function (params) {
|
||||||
|
if (!self.isOpen()) {
|
||||||
|
self.trigger('open');
|
||||||
|
}
|
||||||
|
|
||||||
this.data.query(params, function (data) {
|
this.data.query(params, function (data) {
|
||||||
self.trigger('results:all', {
|
self.trigger('results:all', {
|
||||||
data: data,
|
data: data,
|
||||||
|
8
dist/js/select2.full.js
vendored
8
dist/js/select2.full.js
vendored
@ -1757,10 +1757,10 @@ define('select2/selection/search',[
|
|||||||
// both the `keyup` and `input` events.
|
// both the `keyup` and `input` events.
|
||||||
this.$selection.on('input', '.select2-search--inline', function (evt) {
|
this.$selection.on('input', '.select2-search--inline', function (evt) {
|
||||||
// Unbind the duplicated `keyup` event
|
// Unbind the duplicated `keyup` event
|
||||||
$(this).off('keyup');
|
self.$selection.off('keyup.search');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$selection.on('keyup input', '.select2-search--inline',
|
this.$selection.on('keyup.search input', '.select2-search--inline',
|
||||||
function (evt) {
|
function (evt) {
|
||||||
self.handleSearch(evt);
|
self.handleSearch(evt);
|
||||||
});
|
});
|
||||||
@ -4910,6 +4910,10 @@ define('select2/core',[
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.on('query', function (params) {
|
this.on('query', function (params) {
|
||||||
|
if (!self.isOpen()) {
|
||||||
|
self.trigger('open');
|
||||||
|
}
|
||||||
|
|
||||||
this.data.query(params, function (data) {
|
this.data.query(params, function (data) {
|
||||||
self.trigger('results:all', {
|
self.trigger('results:all', {
|
||||||
data: data,
|
data: data,
|
||||||
|
6
dist/js/select2.full.min.js
vendored
6
dist/js/select2.full.min.js
vendored
File diff suppressed because one or more lines are too long
8
dist/js/select2.js
vendored
8
dist/js/select2.js
vendored
@ -1757,10 +1757,10 @@ define('select2/selection/search',[
|
|||||||
// both the `keyup` and `input` events.
|
// both the `keyup` and `input` events.
|
||||||
this.$selection.on('input', '.select2-search--inline', function (evt) {
|
this.$selection.on('input', '.select2-search--inline', function (evt) {
|
||||||
// Unbind the duplicated `keyup` event
|
// Unbind the duplicated `keyup` event
|
||||||
$(this).off('keyup');
|
self.$selection.off('keyup.search');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$selection.on('keyup input', '.select2-search--inline',
|
this.$selection.on('keyup.search input', '.select2-search--inline',
|
||||||
function (evt) {
|
function (evt) {
|
||||||
self.handleSearch(evt);
|
self.handleSearch(evt);
|
||||||
});
|
});
|
||||||
@ -4910,6 +4910,10 @@ define('select2/core',[
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.on('query', function (params) {
|
this.on('query', function (params) {
|
||||||
|
if (!self.isOpen()) {
|
||||||
|
self.trigger('open');
|
||||||
|
}
|
||||||
|
|
||||||
this.data.query(params, function (data) {
|
this.data.query(params, function (data) {
|
||||||
self.trigger('results:all', {
|
self.trigger('results:all', {
|
||||||
data: data,
|
data: data,
|
||||||
|
4
dist/js/select2.min.js
vendored
4
dist/js/select2.min.js
vendored
File diff suppressed because one or more lines are too long
4
src/js/select2/core.js
vendored
4
src/js/select2/core.js
vendored
@ -272,6 +272,10 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.on('query', function (params) {
|
this.on('query', function (params) {
|
||||||
|
if (!self.isOpen()) {
|
||||||
|
self.trigger('open');
|
||||||
|
}
|
||||||
|
|
||||||
this.data.query(params, function (data) {
|
this.data.query(params, function (data) {
|
||||||
self.trigger('results:all', {
|
self.trigger('results:all', {
|
||||||
data: data,
|
data: data,
|
||||||
|
4
src/js/select2/selection/search.js
vendored
4
src/js/select2/selection/search.js
vendored
@ -84,10 +84,10 @@ define([
|
|||||||
// both the `keyup` and `input` events.
|
// both the `keyup` and `input` events.
|
||||||
this.$selection.on('input', '.select2-search--inline', function (evt) {
|
this.$selection.on('input', '.select2-search--inline', function (evt) {
|
||||||
// Unbind the duplicated `keyup` event
|
// Unbind the duplicated `keyup` event
|
||||||
$(this).off('keyup');
|
self.$selection.off('keyup.search');
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$selection.on('keyup input', '.select2-search--inline',
|
this.$selection.on('keyup.search input', '.select2-search--inline',
|
||||||
function (evt) {
|
function (evt) {
|
||||||
self.handleSearch(evt);
|
self.handleSearch(evt);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user