|
@@ -9,11 +9,11 @@ define([
|
|
|
|
|
|
Search.prototype.render = function (decorated) {
|
|
|
var $search = $(
|
|
|
- '<li class="select2-search select2-search--inline">' +
|
|
|
+ '<span class="select2-search select2-search--inline">' +
|
|
|
'<input class="select2-search__field" type="search" tabindex="-1"' +
|
|
|
' autocorrect="off" autocapitalize="none"' +
|
|
|
' spellcheck="false" role="searchbox" aria-autocomplete="list" />' +
|
|
|
- '</li>'
|
|
|
+ '</span>'
|
|
|
);
|
|
|
|
|
|
this.$searchContainer = $search;
|
|
@@ -24,6 +24,7 @@ define([
|
|
|
var $rendered = decorated.call(this);
|
|
|
|
|
|
this._transferTabIndex();
|
|
|
+ $rendered.append(this.$searchContainer);
|
|
|
|
|
|
return $rendered;
|
|
|
};
|
|
@@ -32,9 +33,12 @@ define([
|
|
|
var self = this;
|
|
|
|
|
|
var resultsId = container.id + '-results';
|
|
|
+ var selectionId = container.id + '-container';
|
|
|
|
|
|
decorated.call(this, container, $container);
|
|
|
|
|
|
+ self.$search.attr('aria-describedby', selectionId);
|
|
|
+
|
|
|
container.on('open', function () {
|
|
|
self.$search.attr('aria-controls', resultsId);
|
|
|
self.$search.trigger('focus');
|
|
@@ -88,8 +92,8 @@ define([
|
|
|
var key = evt.which;
|
|
|
|
|
|
if (key === KEYS.BACKSPACE && self.$search.val() === '') {
|
|
|
- var $previousChoice = self.$searchContainer
|
|
|
- .prev('.select2-selection__choice');
|
|
|
+ var $previousChoice = self.$selection
|
|
|
+ .find('.select2-selection__choice').last();
|
|
|
|
|
|
if ($previousChoice.length > 0) {
|
|
|
var item = Utils.GetData($previousChoice[0], 'data');
|
|
@@ -187,9 +191,6 @@ define([
|
|
|
|
|
|
decorated.call(this, data);
|
|
|
|
|
|
- this.$selection.find('.select2-selection__rendered')
|
|
|
- .append(this.$searchContainer);
|
|
|
-
|
|
|
this.resizeSearch();
|
|
|
if (searchHadFocus) {
|
|
|
this.$search.trigger('focus');
|
|
@@ -222,11 +223,9 @@ define([
|
|
|
Search.prototype.resizeSearch = function () {
|
|
|
this.$search.css('width', '25px');
|
|
|
|
|
|
- var width = '';
|
|
|
+ var width = '100%';
|
|
|
|
|
|
- if (this.$search.attr('placeholder') !== '') {
|
|
|
- width = this.$selection.find('.select2-selection__rendered').width();
|
|
|
- } else {
|
|
|
+ if (this.$search.attr('placeholder') === '') {
|
|
|
var minimumWidth = this.$search.val().length + 1;
|
|
|
|
|
|
width = (minimumWidth * 0.75) + 'em';
|