Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #445 #446

Open
wants to merge 1 commit into
base: dgtkit-4.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -780,9 +780,9 @@ S2.define('select2/utils',[

var id = 0;
Utils.GetUniqueElementId = function (element) {
// Get a unique element Id. If element has no id,
// creates a new unique number, stores it in the id
// attribute and returns the new id.
// Get a unique element Id. If element has no id,
// creates a new unique number, stores it in the id
// attribute and returns the new id.
// If an id already exists, it simply returns it.

var select2Id = element.getAttribute('data-select2-id');
Expand All @@ -801,7 +801,7 @@ S2.define('select2/utils',[

Utils.StoreData = function (element, name, value) {
// Stores an item in the cache for a specified element.
// name is the cache key.
// name is the cache key.
var id = Utils.GetUniqueElementId(element);
if (!Utils.__cache[id]) {
Utils.__cache[id] = {};
Expand All @@ -812,19 +812,19 @@ S2.define('select2/utils',[

Utils.GetData = function (element, name) {
// Retrieves a value from the cache by its key (name)
// name is optional. If no name specified, return
// name is optional. If no name specified, return
// all cache items for the specified element.
// and for a specified element.
var id = Utils.GetUniqueElementId(element);
if (name) {
if (Utils.__cache[id]) {
return Utils.__cache[id][name] != null ?
return Utils.__cache[id][name] != null ?
Utils.__cache[id][name]:
$(element).data(name); // Fallback to HTML5 data attribs.
}
return $(element).data(name); // Fallback to HTML5 data attribs.
} else {
return Utils.__cache[id];
return Utils.__cache[id];
}
};

Expand Down Expand Up @@ -4077,6 +4077,17 @@ S2.define('select2/dropdown/search',[
});
};

// see https://github.com/select2/select2/issues/5993
// using this workaround https://github.com/select2/select2/issues/5993#issuecomment-1050841204
$(document).on('select2:open', () => {
let allFound = document.querySelectorAll('.select2-container--open .select2-search__field');
$(this).one('mouseup keyup', () => {
setTimeout(() => {
allFound[allFound.length - 1].focus();
}, 0);
});
});

Search.prototype.handleSearch = function (evt) {
if (!this._keyUpPrevented) {
var input = this.$search.val();
Expand Down Expand Up @@ -5102,7 +5113,7 @@ S2.define('select2/options',[

$e.attr('ajax--url', Utils.GetData($e[0], 'ajaxUrl'));
Utils.StoreData($e[0], 'ajax-Url', Utils.GetData($e[0], 'ajaxUrl'));

}

var dataset = {};
Expand Down