Skip to content

Commit a8dd05e

Browse files
authored
fix(dropdown): support selection floating or pointing
When pointing or floating was used background color overlayed the border corners of first and last item if menu was not scrolled/overflowed in combination with selection borders were missing inverted upward pointing had wrong arrow direction I also added a new unlimited variant which does not make the selection menu scrollable but shows all items at once instead. This is especially needed in combination with pointing. Otherwise the arrow wont be displayed as the arrow is part of the (overflowing) dom node.
1 parent 4ae1b43 commit a8dd05e

File tree

2 files changed

+88
-23
lines changed

2 files changed

+88
-23
lines changed

src/definitions/modules/dropdown.less

Lines changed: 81 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -435,20 +435,24 @@ select.ui.dropdown {
435435
}
436436

437437
/* Selection Menu */
438-
.ui.selection.dropdown .menu {
438+
.ui.selection.dropdown:not(.unlimited) .menu {
439439
overflow-x: hidden;
440440
overflow-y: auto;
441441
overscroll-behavior: @overscrollBehavior;
442442
backface-visibility: hidden;
443-
border-top-width: 0 !important;
443+
}
444+
.ui.selection.dropdown .menu {
444445
outline: none;
445446
margin: 0 -@menuBorderWidth;
446447
min-width: @menuMinWidth;
447448
width: @menuMinWidth;
448-
border-radius: @selectionMenuBorderRadius;
449449
box-shadow: @selectionMenuBoxShadow;
450450
transition: @selectionMenuTransition;
451451
}
452+
.ui.selection.dropdown:not(.pointing):not(.floating) .menu {
453+
border-top-width: 0;
454+
border-radius: @selectionMenuBorderRadius;
455+
}
452456
.ui.selection.dropdown .menu::after,
453457
.ui.selection.dropdown .menu::before {
454458
display: none;
@@ -471,7 +475,7 @@ select.ui.dropdown {
471475
max-height: @selectionMobileMaxMenuHeight * 0.5;
472476
}
473477
}
474-
.ui.selection.dropdown .menu {
478+
.ui.selection.dropdown:not(.unlimited) .menu {
475479
max-height: @selectionMobileMaxMenuHeight;
476480
}
477481
& when (@variationDropdownLong) {
@@ -492,7 +496,7 @@ select.ui.dropdown {
492496
max-height: @selectionTabletMaxMenuHeight * 0.5;
493497
}
494498
}
495-
.ui.selection.dropdown .menu {
499+
.ui.selection.dropdown:not(.unlimited) .menu {
496500
max-height: @selectionTabletMaxMenuHeight;
497501
}
498502
& when (@variationDropdownLong) {
@@ -513,7 +517,7 @@ select.ui.dropdown {
513517
max-height: @selectionComputerMaxMenuHeight * 0.5;
514518
}
515519
}
516-
.ui.selection.dropdown .menu {
520+
.ui.selection.dropdown:not(.unlimited) .menu {
517521
max-height: @selectionComputerMaxMenuHeight;
518522
}
519523
& when (@variationDropdownLong) {
@@ -534,7 +538,7 @@ select.ui.dropdown {
534538
max-height: @selectionWidescreenMaxMenuHeight * 0.5;
535539
}
536540
}
537-
.ui.selection.dropdown .menu {
541+
.ui.selection.dropdown:not(.unlimited) .menu {
538542
max-height: @selectionWidescreenMaxMenuHeight;
539543
}
540544
& when (@variationDropdownLong) {
@@ -554,6 +558,12 @@ select.ui.dropdown {
554558
white-space: normal;
555559
word-wrap: normal;
556560
}
561+
& when (@variationDropdownPointing) or (@variationDropdownFloating) {
562+
.ui.selection.pointing.dropdown .menu > .item:first-child,
563+
.ui.selection.floating.dropdown .menu > .item:first-child {
564+
border-top: none;
565+
}
566+
}
557567

558568
/* User Item */
559569
.ui.selection.dropdown .menu > .hidden.addition.item {
@@ -621,7 +631,7 @@ select.ui.dropdown {
621631
}
622632

623633
/* Connecting Border */
624-
.ui.active.selection.dropdown {
634+
.ui.active.selection.dropdown:not(.pointing):not(.floating) {
625635
border-bottom-left-radius: @selectionVisibleConnectingBorder !important;
626636
border-bottom-right-radius: @selectionVisibleConnectingBorder !important;
627637
}
@@ -749,29 +759,29 @@ select.ui.dropdown {
749759
}
750760

751761
/* Search Menu */
752-
.ui.search.dropdown .menu {
762+
.ui.search.dropdown:not(.unlimited) .menu {
753763
overflow-x: hidden;
754764
overflow-y: auto;
755765
overscroll-behavior: @overscrollBehavior;
756766
backface-visibility: hidden;
757767
}
758768
@media only screen and (max-width: @largestMobileScreen) {
759-
.ui.search.dropdown .menu {
769+
.ui.search.dropdown:not(.unlimited) .menu {
760770
max-height: @searchMobileMaxMenuHeight;
761771
}
762772
}
763773
@media only screen and (min-width: @tabletBreakpoint) {
764-
.ui.search.dropdown .menu {
774+
.ui.search.dropdown:not(.unlimited) .menu {
765775
max-height: @searchTabletMaxMenuHeight;
766776
}
767777
}
768778
@media only screen and (min-width: @computerBreakpoint) {
769-
.ui.search.dropdown .menu {
779+
.ui.search.dropdown:not(.unlimited) .menu {
770780
max-height: @searchComputerMaxMenuHeight;
771781
}
772782
}
773783
@media only screen and (min-width: @widescreenMonitorBreakpoint) {
774-
.ui.search.dropdown .menu {
784+
.ui.search.dropdown:not(.unlimited) .menu {
775785
max-height: @searchWidescreenMaxMenuHeight;
776786
}
777787
}
@@ -1283,9 +1293,9 @@ select.ui.dropdown {
12831293

12841294
& when (@variationDropdownSelection) {
12851295
/* Selection */
1286-
.ui.ui.upward.selection.dropdown .menu {
1287-
border-top-width: @menuBorderWidth !important;
1288-
border-bottom-width: 0 !important;
1296+
.ui.ui.upward.selection.dropdown:not(.pointing):not(.floating) .menu {
1297+
border-top-width: @menuBorderWidth;
1298+
border-bottom-width: 0;
12891299
box-shadow: @upwardSelectionMenuBoxShadow;
12901300
border-radius: @upwardSelectionMenuBorderRadius;
12911301
}
@@ -1294,21 +1304,23 @@ select.ui.dropdown {
12941304
}
12951305

12961306
/* Active Upward */
1297-
.ui.active.upward.selection.dropdown {
1307+
.ui.active.upward.selection.dropdown:not(.pointing):not(.floating) {
12981308
border-radius: @upwardSelectionVisibleBorderRadius !important;
12991309
}
13001310

13011311
/* Visible Upward */
13021312
.ui.upward.selection.dropdown.visible {
13031313
box-shadow: @upwardSelectionVisibleBoxShadow;
1304-
border-radius: @upwardSelectionVisibleBorderRadius !important;
1314+
&:not(.pointing):not(.floating) {
1315+
border-radius: @upwardSelectionVisibleBorderRadius !important;
1316+
}
13051317
}
13061318

13071319
/* Visible Hover Upward */
13081320
.ui.upward.active.selection.dropdown:hover {
13091321
box-shadow: @upwardSelectionActiveHoverBoxShadow;
13101322
}
1311-
.ui.upward.active.selection.dropdown:hover .menu {
1323+
.ui.upward.active.selection.dropdown:hover:not(.pointing):not(.floating) .menu {
13121324
box-shadow: @upwardSelectionActiveHoverMenuBoxShadow;
13131325
}
13141326
}
@@ -1623,6 +1635,22 @@ select.ui.dropdown {
16231635
z-index: @pointingArrowZIndex;
16241636
}
16251637

1638+
@supports selector(:has(.f)) {
1639+
.ui.pointing.dropdown:not(.upward) .menu:has(:first-child:hover)::after,
1640+
.ui.upward.pointing.dropdown .menu:has(:last-child:hover)::after {
1641+
background: @hoveredItemBackground;
1642+
}
1643+
.ui.pointing.dropdown:not(.upward) .menu:has(.selected.item:first-child)::after,
1644+
.ui.upward.pointing.dropdown .menu:has(.selected.item:last-child)::after {
1645+
background: @selectedBackground;
1646+
}
1647+
}
1648+
1649+
& when (@variationDropdownSelection) {
1650+
.ui.selection.pointing.dropdown > .menu::after {
1651+
box-shadow: @pointingArrowBoxShadowSelection;
1652+
}
1653+
}
16261654
.ui.pointing.dropdown > .menu:not(.hidden)::after {
16271655
top: @pointingArrowOffset;
16281656
left: 50%;
@@ -1768,6 +1796,12 @@ select.ui.dropdown {
17681796
margin: @pointingArrowOffset 0 0;
17691797
}
17701798

1799+
& when (@variationDropdownSelection) {
1800+
.ui.selection.pointing.upward.dropdown .menu::after {
1801+
box-shadow: @pointingUpwardArrowBoxShadowSelection;
1802+
}
1803+
}
1804+
17711805
/* Right Pointing Upward */
17721806
.ui.right.pointing.upward.dropdown:not(.top):not(.bottom) .menu {
17731807
top: auto !important;
@@ -1795,6 +1829,19 @@ select.ui.dropdown {
17951829
}
17961830
}
17971831

1832+
& when (@variationDropdownPointing) or (@variationDropdownFloating) {
1833+
.ui.floating.dropdown .menu .item:first-child,
1834+
.ui.pointing.dropdown .menu .item:first-child {
1835+
border-top-left-radius: @borderRadius;
1836+
border-top-right-radius: @borderRadius;
1837+
}
1838+
.ui.floating.dropdown .menu .item:last-child,
1839+
.ui.pointing.dropdown .menu .item:last-child {
1840+
border-bottom-left-radius: @borderRadius;
1841+
border-bottom-right-radius: @borderRadius;
1842+
}
1843+
}
1844+
17981845
/* --------------------
17991846
Sizes
18001847
--------------------- */
@@ -2008,6 +2055,21 @@ select.ui.dropdown {
20082055
background: @invertedPointingArrowBackground;
20092056
box-shadow: @invertedPointingArrowBoxShadow;
20102057
}
2058+
& when (@variationDropdownUpward) {
2059+
.ui.inverted.upward.pointing.dropdown > .menu::after {
2060+
box-shadow: @invertedPointingUpwardArrowBoxShadow;
2061+
}
2062+
}
2063+
@supports selector(:has(.f)) {
2064+
.ui.inverted.pointing.dropdown:not(.upward) .menu:has(:first-child:hover)::after,
2065+
.ui.inverted.upward.pointing.dropdown .menu:has(:last-child:hover)::after {
2066+
background: @invertedHoveredItemBackground;
2067+
}
2068+
.ui.inverted.pointing.dropdown:not(.upward) .menu:has(.selected.item:first-child)::after,
2069+
.ui.inverted.upward.pointing.dropdown .menu:has(.selected.item:last-child)::after {
2070+
background: @invertedSelectedBackground;
2071+
}
2072+
}
20112073
}
20122074
}
20132075

src/themes/default/modules/dropdown.variables

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@
292292
@additionZIndex: @hoveredZIndex + 1;
293293

294294
/* Hovered */
295-
@hoveredItemBackground: @transparentBlack;
295+
@hoveredItemBackground: #f2f2f2;
296296
@hoveredItemColor: @selectedTextColor;
297297
@hoveredZIndex: @menuZIndex + 2;
298298

@@ -311,7 +311,7 @@
311311
@activeItemColor: @selectedTextColor;
312312

313313
/* Selected */
314-
@selectedBackground: @subtleTransparentBlack;
314+
@selectedBackground: #f7f7f7;
315315
@selectedColor: @selectedTextColor;
316316

317317
/* Clearable */
@@ -382,6 +382,7 @@
382382
@pointingArrowBackground: @white;
383383
@pointingArrowZIndex: 2;
384384
@pointingArrowBoxShadow: -@menuBorderWidth -@menuBorderWidth 0 0 @menuBorderColor;
385+
@pointingArrowBoxShadowSelection: -@menuBorderWidth -@menuBorderWidth 0 0 @selectionVisibleBorderColor;
385386
@pointingArrowSize: @relative7px;
386387

387388
@pointingMenuDistance: @mini;
@@ -390,6 +391,7 @@
390391
/* Pointing Upward */
391392
@pointingUpwardMenuBorderRadius: @borderRadius;
392393
@pointingUpwardArrowBoxShadow: @menuBorderWidth @menuBorderWidth 0 0 @menuBorderColor;
394+
@pointingUpwardArrowBoxShadowSelection: @menuBorderWidth @menuBorderWidth 0 0 @selectionVisibleBorderColor;
393395

394396
/* Scrollhint */
395397
@scrollhintWidth: 0.25em;
@@ -416,15 +418,16 @@
416418

417419
@invertedPointingArrowBackground: @black;
418420
@invertedPointingArrowBoxShadow: -@menuBorderWidth -@menuBorderWidth 0 0 @invertedMenuBorderColor;
421+
@invertedPointingUpwardArrowBoxShadow: @menuBorderWidth @menuBorderWidth 0 0 @invertedMenuBorderColor;
419422

420-
@invertedHoveredItemBackground: @transparentWhite;
423+
@invertedHoveredItemBackground: #2d2e2f;
421424
@invertedHoveredItemColor: @invertedMenuColor;
422425

423426
@invertedActiveItemBackground: transparent;
424427
@invertedActiveItemColor: @invertedMenuColor;
425428
@invertedActiveItemBoxShadow: none;
426429

427-
@invertedSelectedBackground: @strongTransparentWhite;
430+
@invertedSelectedBackground: #3d3e3f;
428431
@invertedSelectedColor: @invertedMenuColor;
429432

430433
@invertedMenuHeaderColor: @white;

0 commit comments

Comments
 (0)