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

More options #6263

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 22 additions & 14 deletions dist/js/select2.full.js
Expand Up @@ -1169,7 +1169,7 @@ S2.define('select2/results',[
// When the dropdown is closed, aria-expended="false"
self.$results.attr('aria-expanded', 'false');
self.$results.attr('aria-hidden', 'true');
self.$results.removeAttr('aria-activedescendant');
self.$results[0].removeAttribute('aria-activedescendant');
});

container.on('results:toggle', function () {
Expand Down Expand Up @@ -1502,8 +1502,8 @@ S2.define('select2/selection/base',[
container.on('close', function () {
// When the dropdown is closed, aria-expanded="false"
self.$selection.attr('aria-expanded', 'false');
self.$selection.removeAttr('aria-activedescendant');
self.$selection.removeAttr('aria-owns');
self.$selection[0].removeAttribute('aria-activedescendant');
self.$selection[0].removeAttribute('aria-owns');

self.$selection.trigger('focus');

Expand Down Expand Up @@ -1671,7 +1671,7 @@ S2.define('select2/selection/single',[
SingleSelection.prototype.clear = function () {
var $rendered = this.$selection.find('.select2-selection__rendered');
$rendered.empty();
$rendered.removeAttr('title'); // clear tooltip on empty
$rendered[0].removeAttribute('title'); // clear tooltip on empty
};

SingleSelection.prototype.display = function (data, container) {
Expand Down Expand Up @@ -1703,7 +1703,7 @@ S2.define('select2/selection/single',[
if (title) {
$rendered.attr('title', title);
} else {
$rendered.removeAttr('title');
$rendered[0].removeAttribute('title');
}
};

Expand Down Expand Up @@ -2102,8 +2102,8 @@ S2.define('select2/selection/search',[
container.on('close', function () {
self.$search.val('');
self.resizeSearch();
self.$search.removeAttr('aria-controls');
self.$search.removeAttr('aria-activedescendant');
self.$search[0].removeAttribute('aria-controls');
self.$search[0].removeAttribute('aria-activedescendant');
self.$search.trigger('focus');
});

Expand All @@ -2125,7 +2125,7 @@ S2.define('select2/selection/search',[
if (params.data._resultId) {
self.$search.attr('aria-activedescendant', params.data._resultId);
} else {
self.$search.removeAttr('aria-activedescendant');
self.$search[0].removeAttribute('aria-activedescendant');
}
});

Expand Down Expand Up @@ -2308,7 +2308,11 @@ S2.define('select2/selection/selectionCss',[
Utils.copyNonInternalCssClasses($selection[0], this.$element[0]);
}

$selection.addClass(selectionCssClass);
selectionCssClass.trim().split(' ').forEach(function(cssClass) {
if(cssClass.length > 0) {
$selection[0].classList.add(cssClass);
}
});

return $selection;
};
Expand Down Expand Up @@ -4256,8 +4260,8 @@ S2.define('select2/dropdown/search',[

container.on('close', function () {
self.$search.attr('tabindex', -1);
self.$search.removeAttr('aria-controls');
self.$search.removeAttr('aria-activedescendant');
self.$search[0].removeAttribute('aria-controls');
self.$search[0].removeAttribute('aria-activedescendant');

self.$search.val('');
self.$search.trigger('blur');
Expand Down Expand Up @@ -4285,7 +4289,7 @@ S2.define('select2/dropdown/search',[
if (params.data._resultId) {
self.$search.attr('aria-activedescendant', params.data._resultId);
} else {
self.$search.removeAttr('aria-activedescendant');
self.$search[0].removeAttribute('aria-activedescendant');
}
});
};
Expand Down Expand Up @@ -4849,7 +4853,11 @@ S2.define('select2/dropdown/dropdownCss',[
Utils.copyNonInternalCssClasses($dropdown[0], this.$element[0]);
}

$dropdown.addClass(dropdownCssClass);
dropdownCssClass.trim().split(' ').forEach(function(cssClass) {
if(cssClass.length > 0) {
$dropdown[0].classList.add(cssClass);
}
});

return $dropdown;
};
Expand Down Expand Up @@ -5140,7 +5148,7 @@ S2.define('select2/defaults',[
if (options.multiple) {
options.selectionAdapter = Utils.Decorate(
options.selectionAdapter,
SelectionSearch
options.searchDecorator || SelectionSearch
);
}

Expand Down
2 changes: 1 addition & 1 deletion dist/js/select2.full.min.js

Large diffs are not rendered by default.

36 changes: 22 additions & 14 deletions dist/js/select2.js
Expand Up @@ -1169,7 +1169,7 @@ S2.define('select2/results',[
// When the dropdown is closed, aria-expended="false"
self.$results.attr('aria-expanded', 'false');
self.$results.attr('aria-hidden', 'true');
self.$results.removeAttr('aria-activedescendant');
self.$results[0].removeAttribute('aria-activedescendant');
});

container.on('results:toggle', function () {
Expand Down Expand Up @@ -1502,8 +1502,8 @@ S2.define('select2/selection/base',[
container.on('close', function () {
// When the dropdown is closed, aria-expanded="false"
self.$selection.attr('aria-expanded', 'false');
self.$selection.removeAttr('aria-activedescendant');
self.$selection.removeAttr('aria-owns');
self.$selection[0].removeAttribute('aria-activedescendant');
self.$selection[0].removeAttribute('aria-owns');

self.$selection.trigger('focus');

Expand Down Expand Up @@ -1671,7 +1671,7 @@ S2.define('select2/selection/single',[
SingleSelection.prototype.clear = function () {
var $rendered = this.$selection.find('.select2-selection__rendered');
$rendered.empty();
$rendered.removeAttr('title'); // clear tooltip on empty
$rendered[0].removeAttribute('title'); // clear tooltip on empty
};

SingleSelection.prototype.display = function (data, container) {
Expand Down Expand Up @@ -1703,7 +1703,7 @@ S2.define('select2/selection/single',[
if (title) {
$rendered.attr('title', title);
} else {
$rendered.removeAttr('title');
$rendered[0].removeAttribute('title');
}
};

Expand Down Expand Up @@ -2102,8 +2102,8 @@ S2.define('select2/selection/search',[
container.on('close', function () {
self.$search.val('');
self.resizeSearch();
self.$search.removeAttr('aria-controls');
self.$search.removeAttr('aria-activedescendant');
self.$search[0].removeAttribute('aria-controls');
self.$search[0].removeAttribute('aria-activedescendant');
self.$search.trigger('focus');
});

Expand All @@ -2125,7 +2125,7 @@ S2.define('select2/selection/search',[
if (params.data._resultId) {
self.$search.attr('aria-activedescendant', params.data._resultId);
} else {
self.$search.removeAttr('aria-activedescendant');
self.$search[0].removeAttribute('aria-activedescendant');
}
});

Expand Down Expand Up @@ -2308,7 +2308,11 @@ S2.define('select2/selection/selectionCss',[
Utils.copyNonInternalCssClasses($selection[0], this.$element[0]);
}

$selection.addClass(selectionCssClass);
selectionCssClass.trim().split(' ').forEach(function(cssClass) {
if(cssClass.length > 0) {
$selection[0].classList.add(cssClass);
}
});

return $selection;
};
Expand Down Expand Up @@ -4256,8 +4260,8 @@ S2.define('select2/dropdown/search',[

container.on('close', function () {
self.$search.attr('tabindex', -1);
self.$search.removeAttr('aria-controls');
self.$search.removeAttr('aria-activedescendant');
self.$search[0].removeAttribute('aria-controls');
self.$search[0].removeAttribute('aria-activedescendant');

self.$search.val('');
self.$search.trigger('blur');
Expand Down Expand Up @@ -4285,7 +4289,7 @@ S2.define('select2/dropdown/search',[
if (params.data._resultId) {
self.$search.attr('aria-activedescendant', params.data._resultId);
} else {
self.$search.removeAttr('aria-activedescendant');
self.$search[0].removeAttribute('aria-activedescendant');
}
});
};
Expand Down Expand Up @@ -4849,7 +4853,11 @@ S2.define('select2/dropdown/dropdownCss',[
Utils.copyNonInternalCssClasses($dropdown[0], this.$element[0]);
}

$dropdown.addClass(dropdownCssClass);
dropdownCssClass.trim().split(' ').forEach(function(cssClass) {
if(cssClass.length > 0) {
$dropdown[0].classList.add(cssClass);
}
});

return $dropdown;
};
Expand Down Expand Up @@ -5140,7 +5148,7 @@ S2.define('select2/defaults',[
if (options.multiple) {
options.selectionAdapter = Utils.Decorate(
options.selectionAdapter,
SelectionSearch
options.searchDecorator || SelectionSearch
);
}

Expand Down
2 changes: 1 addition & 1 deletion dist/js/select2.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/pages/03.configuration/01.options-api/docs.md
Expand Up @@ -31,6 +31,7 @@ This is a list of all the Select2 configuration options.
| `multiple` | boolean | `false` | This option enables multi-select (pillbox) mode. Select2 will automatically map the value of the `multiple` HTML attribute to this option during initialization. |
| `placeholder` | string or object | `null` | Specifies the [placeholder](/placeholders) for the control. |
| `resultsAdapter` | | `ResultsAdapter` | Used to override the built-in [ResultsAdapter](/advanced/default-adapters/results). |
| `searchDecorator` | | `SelectionSearch` | Used to override the built-in `SelectionSearch` decorator. This decorator applies only if you're using one of built-in adapters for `selectionAdapter` and set option `multiple` value to `true`. Otherwise this option has no effect.
| `selectionAdapter` | | `SingleSelection` or `MultipleSelection`, depending on the value of `multiple`. | Used to override the built-in [SelectionAdapter](/advanced/default-adapters/selection). |
| `selectionCssClass` | string | `''` | Adds additional CSS classes to the selection container. The helper `:all:` can be used to add all CSS classes present on the original `<select>` element. |
| `selectOnClose` | boolean | `false` | Implements [automatic selection](/dropdown#automatic-selection) when the dropdown is closed. |
Expand Down
2 changes: 1 addition & 1 deletion src/js/select2/defaults.js
Expand Up @@ -195,7 +195,7 @@ define([
if (options.multiple) {
options.selectionAdapter = Utils.Decorate(
options.selectionAdapter,
SelectionSearch
options.searchDecorator || SelectionSearch
);
}

Expand Down