Skip to content

Commit 1d06e9d

Browse files
authored
fix(dropdown): clearable inline support
Inline (or no selection) dropdowns did not support clearable (while SUI does and even the FUI docs mention it)
1 parent 1408be0 commit 1d06e9d

File tree

3 files changed

+48
-24
lines changed

3 files changed

+48
-24
lines changed

src/definitions/modules/dropdown.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ $.fn.dropdown = function(parameters) {
359359
if( !module.has.menu() ) {
360360
module.create.menu();
361361
}
362-
if ( module.is.selection() && module.is.clearable() && !module.has.clearItem() ) {
362+
if ( module.is.clearable() && !module.has.clearItem() ) {
363363
module.verbose('Adding clear icon');
364364
$clear = $('<i />')
365365
.addClass('remove icon')

src/definitions/modules/dropdown.less

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
.ui.dropdown:not(.labeled) > .dropdown.icon {
8888
position: relative;
8989
width: auto;
90+
min-width: @dropdownIconMinWidth;
9091
font-size: @dropdownIconSize;
9192
margin: @dropdownIconMargin;
9293
}
@@ -771,29 +772,44 @@ select.ui.dropdown {
771772
}
772773
}
773774

774-
/* Clearable Selection */
775-
.ui.dropdown > .remove.icon {
776-
cursor: pointer;
777-
font-size: @dropdownIconSize;
778-
margin: @selectionIconMargin;
779-
padding: @selectionIconPadding;
780-
right: 3em;
781-
top: @selectionVerticalPadding;
782-
position: absolute;
783-
opacity: 0.6;
784-
z-index: @selectionIconZIndex;
785-
}
775+
& when (@variationDropdownClear) {
776+
/* Clearable Selection */
777+
.ui.dropdown > .remove.icon {
778+
cursor: pointer;
779+
font-size: @dropdownIconSize;
780+
margin: @selectionIconMargin;
781+
padding: @selectionIconPadding;
782+
right: @clearableIconPosition;
783+
top: @selectionVerticalPadding;
784+
position: absolute;
785+
opacity: @clearableIconOpacity;
786+
z-index: @selectionIconZIndex;
787+
}
788+
.ui.selection.dropdown > .remove.icon {
789+
right: @clearableIconSelectionPosition;
790+
}
791+
.ui.inline.dropdown > .remove.icon {
792+
right: @clearableIconInlinePosition;
793+
}
786794

787-
.ui.clearable.dropdown .text,
788-
.ui.clearable.dropdown a:last-of-type {
789-
margin-right: 1.5em;
790-
}
795+
.ui.clearable.dropdown .text,
796+
.ui.clearable.dropdown a:last-of-type {
797+
margin-right: @clearableTextMargin;
798+
}
791799

792-
.ui.dropdown select.noselection ~ .remove.icon,
793-
.ui.dropdown input[value=''] ~ .remove.icon,
794-
.ui.dropdown input:not([value]) ~ .remove.icon,
795-
.ui.dropdown.loading > .remove.icon {
796-
display: none;
800+
.ui.dropdown select.noselection ~ .remove.icon,
801+
.ui.dropdown input[value=''] ~ .remove.icon,
802+
.ui.dropdown input:not([value]) ~ .remove.icon,
803+
.ui.dropdown.loading > .remove.icon {
804+
display: none;
805+
}
806+
807+
.ui.dropdown:not(.selection) > .remove.icon ~ .dropdown.icon {
808+
margin-left: @clearableIconMargin;
809+
}
810+
.ui.dropdown:not(.selection) > .remove.icon {
811+
margin-top: -@clearableIconMarginTop;
812+
}
797813
}
798814

799815
& when (@variationDropdownMultiple) {
@@ -1111,11 +1127,12 @@ select.ui.dropdown {
11111127
/*--------------------
11121128
Clear
11131129
----------------------*/
1114-
1130+
.ui.dropdown > .remove.icon,
11151131
.ui.dropdown > .clear.dropdown.icon {
11161132
opacity: @clearableIconOpacity;
11171133
transition: opacity @defaultDuration @defaultEasing;
11181134
}
1135+
.ui.dropdown > .remove.icon:hover,
11191136
.ui.dropdown > .clear.dropdown.icon:hover {
11201137
opacity: @clearableIconActiveOpacity;
11211138
}

src/themes/default/modules/dropdown.variables

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
/* Icon */
2222
@dropdownIconSize: @relative12px;
2323
@dropdownIconMargin: 0 0 0 1em;
24+
@dropdownIconMinWidth: 1em;
2425

2526
/* Current Text */
2627
@textTransition: none;
@@ -310,8 +311,14 @@
310311
@selectedColor: @selectedTextColor;
311312

312313
/* Clearable */
313-
@clearableIconOpacity: 0.8;
314+
@clearableIconOpacity: 0.6;
314315
@clearableIconActiveOpacity: 1;
316+
@clearableTextMargin: 1.5em;
317+
@clearableIconMargin: 1.5em;
318+
@clearableIconMarginTop: 1.35em;
319+
@clearableIconPosition: 2em;
320+
@clearableIconSelectionPosition: 3em;
321+
@clearableIconInlinePosition: 2.2em;
315322

316323
/*-------------------
317324
Variations

0 commit comments

Comments
 (0)