Fixed the selectOnClose
option
The `selectOnClose` option did not work in production because we were decorating the `dropdownAdapter` instead of the `resultsAdpater` when automatically generating the adapters. This has now been fixed, and the option should work without errors in production. This also adds documentation for the `selectOnClose` option. This closes https://github.com/select2/select2/issues/2953.
This commit is contained in:
parent
686f846fa5
commit
80bda0ad55
7
dist/js/select2.amd.full.js
vendored
7
dist/js/select2.amd.full.js
vendored
@ -3650,13 +3650,6 @@ define('select2/defaults',[
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.selectOnClose) {
|
|
||||||
options.dropdownAdapter = Utils.Decorate(
|
|
||||||
options.dropdownAdapter,
|
|
||||||
SelectOnClose
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
options.dropdownAdapter = Utils.Decorate(
|
options.dropdownAdapter = Utils.Decorate(
|
||||||
options.dropdownAdapter,
|
options.dropdownAdapter,
|
||||||
AttachBody
|
AttachBody
|
||||||
|
7
dist/js/select2.amd.js
vendored
7
dist/js/select2.amd.js
vendored
@ -3650,13 +3650,6 @@ define('select2/defaults',[
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.selectOnClose) {
|
|
||||||
options.dropdownAdapter = Utils.Decorate(
|
|
||||||
options.dropdownAdapter,
|
|
||||||
SelectOnClose
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
options.dropdownAdapter = Utils.Decorate(
|
options.dropdownAdapter = Utils.Decorate(
|
||||||
options.dropdownAdapter,
|
options.dropdownAdapter,
|
||||||
AttachBody
|
AttachBody
|
||||||
|
7
dist/js/select2.full.js
vendored
7
dist/js/select2.full.js
vendored
@ -4088,13 +4088,6 @@ define('select2/defaults',[
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.selectOnClose) {
|
|
||||||
options.dropdownAdapter = Utils.Decorate(
|
|
||||||
options.dropdownAdapter,
|
|
||||||
SelectOnClose
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
options.dropdownAdapter = Utils.Decorate(
|
options.dropdownAdapter = Utils.Decorate(
|
||||||
options.dropdownAdapter,
|
options.dropdownAdapter,
|
||||||
AttachBody
|
AttachBody
|
||||||
|
2
dist/js/select2.full.min.js
vendored
2
dist/js/select2.full.min.js
vendored
File diff suppressed because one or more lines are too long
7
dist/js/select2.js
vendored
7
dist/js/select2.js
vendored
@ -4088,13 +4088,6 @@ define('select2/defaults',[
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.selectOnClose) {
|
|
||||||
options.dropdownAdapter = Utils.Decorate(
|
|
||||||
options.dropdownAdapter,
|
|
||||||
SelectOnClose
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
options.dropdownAdapter = Utils.Decorate(
|
options.dropdownAdapter = Utils.Decorate(
|
||||||
options.dropdownAdapter,
|
options.dropdownAdapter,
|
||||||
AttachBody
|
AttachBody
|
||||||
|
2
dist/js/select2.min.js
vendored
2
dist/js/select2.min.js
vendored
File diff suppressed because one or more lines are too long
@ -688,17 +688,29 @@ ajax: {
|
|||||||
it will appear in the same location within the DOM as the rest of Select2.
|
it will appear in the same location within the DOM as the rest of Select2.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<dl class="dl-horizontal">
|
<div class="row">
|
||||||
<dt>Adapter</dt>
|
<div class="col-sm-4">
|
||||||
<dd>
|
<dl class="dl-horizontal">
|
||||||
<code title="select2/dropdown">DropdownAdapter</code>
|
<dt>Adapter</dt>
|
||||||
</dd>
|
<dd>
|
||||||
|
<code title="select2/dropdown">DropdownAdapter</code>
|
||||||
|
</dd>
|
||||||
|
|
||||||
<dt>Decorator</dt>
|
<dt>Decorator</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<code title="select2/dropdown/attachContainer">AttachContainer</code>
|
<code title="select2/dropdown/attachContainer">AttachContainer</code>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<div class="alert alert-warning">
|
||||||
|
<strong>Check your build.</strong> This module is only included in the
|
||||||
|
<a href="index.html#builds-full" class="alert-link">full builds</a> of
|
||||||
|
Select2.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
<strong>
|
<strong>
|
||||||
@ -734,6 +746,30 @@ ajax: {
|
|||||||
A search box is added to the top of the dropdown automatically for select
|
A search box is added to the top of the dropdown automatically for select
|
||||||
boxes where only a single option can be selected.
|
boxes where only a single option can be selected.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<h2 id="dropdown-select-on-close">
|
||||||
|
Select the highlighted option on close
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
When users close the dropdown, the last highlighted option can be
|
||||||
|
automatically selected. This is commonly used in combination with
|
||||||
|
<a href="#tags">tagging</a> and <a href="#placeholder">placeholders</a>
|
||||||
|
and other situations where the user is required to select an option, or
|
||||||
|
they need to be able to quickly select multiple options.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<dl class="dl-horizontal">
|
||||||
|
<dt>Adapter</dt>
|
||||||
|
<dd>
|
||||||
|
<code title="select2/results">ResultsAdapter</code>
|
||||||
|
</dd>
|
||||||
|
|
||||||
|
<dt>Decorator</dt>
|
||||||
|
<dd>
|
||||||
|
<code title="select2/dropdown/selectOnClose">SelectOnClose</code>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="events">
|
<section id="events">
|
||||||
@ -1053,9 +1089,10 @@ $.fn.select2.default2.set("theme", "classic");
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<strong>The compatibility modules are only included in the full builds of
|
<strong>The compatibility modules are only included in the
|
||||||
Select2</strong>. These files end in <code>.full.js</code>, and the
|
<a href="index.html#builds-full" class="alert-link">full builds</a> of
|
||||||
compatibility modules are prefixed with <code>select2/compat</code>.
|
Select2</strong>. These files end in <code>.full.js</code>, and the
|
||||||
|
compatibility modules are prefixed with <code>select2/compat</code>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h2 id="initSelection">
|
<h2 id="initSelection">
|
||||||
@ -1064,7 +1101,9 @@ $.fn.select2.default2.set("theme", "classic");
|
|||||||
|
|
||||||
<p class="alert alert-warning">
|
<p class="alert alert-warning">
|
||||||
<a href="announcements-4.0.html#removed-initselection" class="alert-link">Deprecated in Select2 4.0.</a>
|
<a href="announcements-4.0.html#removed-initselection" class="alert-link">Deprecated in Select2 4.0.</a>
|
||||||
This has been replaced by another option.
|
This has been replaced by another option and is only available in the
|
||||||
|
<a href="index.html#builds-full" class="alert-link">full builds</a> of
|
||||||
|
Select2.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -1111,7 +1150,9 @@ $.fn.select2.default2.set("theme", "classic");
|
|||||||
|
|
||||||
<p class="alert alert-warning">
|
<p class="alert alert-warning">
|
||||||
<a href="announcements-4.0.html#query-to-data-adapter" class="alert-link">Deprecated in Select2 4.0.</a>
|
<a href="announcements-4.0.html#query-to-data-adapter" class="alert-link">Deprecated in Select2 4.0.</a>
|
||||||
This has been replaced by another option.
|
This has been replaced by another option and is only available in the
|
||||||
|
<a href="index.html#builds-full" class="alert-link">full builds</a> of
|
||||||
|
Select2.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
14
src/js/select2/defaults.js
vendored
14
src/js/select2/defaults.js
vendored
@ -128,6 +128,13 @@ define([
|
|||||||
HidePlaceholder
|
HidePlaceholder
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.selectOnClose) {
|
||||||
|
options.resultsAdapter = Utils.Decorate(
|
||||||
|
options.resultsAdapter,
|
||||||
|
SelectOnClose
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.dropdownAdapter == null) {
|
if (options.dropdownAdapter == null) {
|
||||||
@ -146,13 +153,6 @@ define([
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.selectOnClose) {
|
|
||||||
options.dropdownAdapter = Utils.Decorate(
|
|
||||||
options.dropdownAdapter,
|
|
||||||
SelectOnClose
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
options.dropdownAdapter = Utils.Decorate(
|
options.dropdownAdapter = Utils.Decorate(
|
||||||
options.dropdownAdapter,
|
options.dropdownAdapter,
|
||||||
AttachBody
|
AttachBody
|
||||||
|
Loading…
Reference in New Issue
Block a user