File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change 1717 <span class =" vti__dropdown-arrow" >{{ open ? "▲" : "▼" }}</span >
1818 </slot >
1919 </span >
20- <ul ref =" list" class =" vti__dropdown-list" v-show =" open" >
20+ <ul ref =" list" class =" vti__dropdown-list" v-show =" open" :class = " dropdownOpenDirection " >
2121 <li
2222 v-for =" (pb, index) in sortedCountries"
2323 :key =" pb.iso2 + (pb.preferred ? '-preferred' : '')"
@@ -235,6 +235,7 @@ export default {
235235 typeToFindInput: ' ' ,
236236 typeToFindTimer: null ,
237237 cursorPosition: 0 ,
238+ dropdownOpenDirection: ' below' ,
238239 };
239240 },
240241 computed: {
@@ -317,6 +318,7 @@ export default {
317318 open (isDropdownOpened ) {
318319 // Emit open and close events
319320 if (isDropdownOpened) {
321+ this .setDropdownPosition ();
320322 this .$emit (' open' );
321323 } else {
322324 this .$emit (' close' );
@@ -585,6 +587,15 @@ export default {
585587 this .selectedIndex = this .sortedCountries .map (c => c .iso2 ).indexOf (this .activeCountry .iso2 );
586588 this .open = false ;
587589 },
590+ setDropdownPosition () {
591+ const spaceBelow = window .innerHeight - this .$el .getBoundingClientRect ().bottom ;
592+ const hasEnoughSpaceBelow = spaceBelow > 200 ;
593+ if (hasEnoughSpaceBelow) {
594+ this .dropdownOpenDirection = ' below' ;
595+ } else {
596+ this .dropdownOpenDirection = ' above' ;
597+ }
598+ },
588599 },
589600};
590601 </script >
@@ -646,12 +657,18 @@ export default {
646657 max-height : 200px ;
647658 overflow-y : scroll ;
648659 position : absolute ;
649- top : 33px ;
650660 left : -1px ;
651661 background-color : #fff ;
652662 border : 1px solid #ccc ;
653663 width : 390px ;
654664}
665+ .vti__dropdown-list.below {
666+ top : 33px ;
667+ }
668+ .vti__dropdown-list.above {
669+ top : auto ;
670+ bottom : 100% ;
671+ }
655672.vti__dropdown-arrow {
656673 transform : scaleY (0.5 );
657674 display : inline-block ;
You can’t perform that action at this time.
0 commit comments