1
0
mirror of synced 2025-02-16 20:13:16 +03:00

Style clear icon in multiple selects

The `AllowClear` decorator appears to work fine with multiple
selects, so we've chosen to remove remove it. This adds some
styling and fixes the check so it all works as expected.

This closes https://github.com/select2/select2/issues/2903.
This commit is contained in:
Kevin Brown 2015-01-09 11:01:34 -05:00
parent fe1374fd11
commit 7edf0e3ebe
11 changed files with 36 additions and 9 deletions

11
dist/css/select2.css vendored
View File

@ -155,11 +155,18 @@
.select2-container--default .select2-selection--multiple .select2-selection__rendered {
list-style: none;
margin: 0;
padding: 0 5px; }
padding: 0 5px;
width: 100%; }
.select2-container--default .select2-selection--multiple .select2-selection__placeholder {
color: #999;
margin-top: 5px;
float: left; }
.select2-container--default .select2-selection--multiple .select2-selection__clear {
cursor: pointer;
float: right;
font-weight: bold;
margin-top: 5px;
margin-right: 10px; }
.select2-container--default .select2-selection--multiple .select2-selection__choice {
background-color: #e4e4e4;
border: 1px solid #aaa;
@ -316,6 +323,8 @@
list-style: none;
margin: 0;
padding: 0 5px; }
.select2-container--classic .select2-selection--multiple .select2-selection__clear {
display: none; }
.select2-container--classic .select2-selection--multiple .select2-selection__choice {
background-color: #e4e4e4;
border: 1px solid #aaa;

File diff suppressed because one or more lines are too long

View File

@ -1078,7 +1078,8 @@ define('select2/selection/allowClear',[
AllowClear.prototype.update = function (decorated, data) {
decorated.call(this, data);
if (this.$selection.find('.select2-selection__placeholder').length > 0) {
if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
data.length === 0) {
return;
}

View File

@ -1078,7 +1078,8 @@ define('select2/selection/allowClear',[
AllowClear.prototype.update = function (decorated, data) {
decorated.call(this, data);
if (this.$selection.find('.select2-selection__placeholder').length > 0) {
if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
data.length === 0) {
return;
}

View File

@ -10613,7 +10613,8 @@ define('select2/selection/allowClear',[
AllowClear.prototype.update = function (decorated, data) {
decorated.call(this, data);
if (this.$selection.find('.select2-selection__placeholder').length > 0) {
if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
data.length === 0) {
return;
}

File diff suppressed because one or more lines are too long

3
dist/js/select2.js vendored
View File

@ -1506,7 +1506,8 @@ define('select2/selection/allowClear',[
AllowClear.prototype.update = function (decorated, data) {
decorated.call(this, data);
if (this.$selection.find('.select2-selection__placeholder').length > 0) {
if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
data.length === 0) {
return;
}

File diff suppressed because one or more lines are too long

View File

@ -26,7 +26,8 @@ define([
AllowClear.prototype.update = function (decorated, data) {
decorated.call(this, data);
if (this.$selection.find('.select2-selection__placeholder').length > 0) {
if (this.$selection.find('.select2-selection__placeholder').length > 0 ||
data.length === 0) {
return;
}

View File

@ -18,6 +18,10 @@
padding: 0 5px;
}
.select2-selection__clear {
display: none;
}
.select2-selection__choice {
background-color: #e4e4e4;

View File

@ -8,6 +8,7 @@
list-style: none;
margin: 0;
padding: 0 5px;
width: 100%;
}
.select2-selection__placeholder {
@ -18,6 +19,14 @@
float: left;
}
.select2-selection__clear {
cursor: pointer;
float: right;
font-weight: bold;
margin-top: 5px;
margin-right: 10px;
}
.select2-selection__choice {
background-color: #e4e4e4;