question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hack: Showing dropdown on top of select input

See original GitHub issue

Saw some issues on this topic, but no activity or merged PRs. Here’s a quick hack you can do to get the dropdown menu going in the up direction. Paste the following into your CSS file. Wrap your <Select /> component in a div with the select-up class included.

.select-up .Select-menu-outer {
    position: absolute !important;
    top: auto !important;
    bottom: calc(100% - 1px) !important;
    border-bottom-left-radius: 0px !important;
    border-bottom-right-radius: 0px !important;
    border-top-left-radius: 5px !important;
    border-top-right-radius: 5px !important;
}

.select-up .is-open .Select-control {
    border-top-right-radius: 0 !important;
    border-top-left-radius: 0 !important;
    border-bottom-right-radius: 5px !important;
    border-bottom-left-radius: 5px !important;
}

Example Usage:

<div className="select-up">
    <Select />
</div>

Preview: screen shot 2017-03-30 at 12 31 58 pm

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:49
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

14reactions
ROSHANDBITcommented, Mar 9, 2020

add to <select /> menuPlacement = “top”

11reactions
MartinHaeuslercommented, Jul 8, 2017

Hi, based on your idea with the CSS modification I created a quick-and-dirty wrapper component that performs some DOM node calculations and tries to estimate the visual height of the menu. When this estimate fits into the screen below the select element, the overlay is displayed below it, otherwise it is displayed above the select element.

https://gist.github.com/MartinHaeusler/6dfc3769df20f534a150efda39573f0d

This is really dirty stuff, but it “works for me”. If you use different font heights etc. then you might need to adjust the constants.

This functionality (not my implementation of it, mind you) desperately needs to be part of react-select.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML Select Drop Down Option Z-index - css - Stack Overflow
Open select dropdown options; Same time hover on navigation menu items; Now the navigation items are going behind the option list (not behind...
Read more >
Quick Tip: CSS Only Dropdowns With The Checkbox Hack
In this quick tip, we are going to take a look at a CSS only technique for creating dropdowns. It revolves around the...
Read more >
Line-by-line: advanced CSS tricks for click-to-open drop-down ...
To make the box open when the top content is clicked, you need to add the dropdown class to the combobox , and...
Read more >
Dropdowns - Bootstrap
Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They're made interactive with the included Bootstrap dropdown ...
Read more >
Solved with CSS! Dropdown Menus
A common UI pattern that we see on the web are dropdown menus. They're used to display related information in pieces, without overwhelming...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found