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.

[question] Dropdown: adjust dropdown menu height and content overflow

See original GitHub issue

I’m working to accommodate mobile devices in my application, and we have various large dropdown lists to render. From pretty much any point on the page, our dropdown menus exceed the page size. Unfortunately, this isn’t a scrollable page, but more of the mobile-app style with full screen content.

Is there a good way to apply some styling to control menu size and overflow? I imagine I could just apply some more nested css selectors (although I’ve been going strong with flat classes thus far):

.my-component .dropdown-menu {
  max-height: $really-tiny-mobile-menu-height;
  overflow-y: scroll;

  @media (min-width: $not-tiny-mobile){
    // media query stuff
  }
}

But beyond that, any ideas for calculating height based on the position of the element on the page and the size of the page? Maybe just use a mounted hook to grab an element position, and yada-yada some size calc logic? Seems a bit manual. Thoughts?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
alexsasharegancommented, May 26, 2017

I’m finding some interesting data by using element.getBoundingClientRect(). Among the object props returned are the x, y, w, & h of the element relative to the viewport.

0reactions
tmorehousecommented, May 26, 2017

No objections.

I’ll post the CSS here once I find it

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Set Height for the Drop Down of Select box
In Case of setting size (height/width) and fitting the selection list in the pop up then try the following in VFPage- Salesforce:
Read more >
Overflowing content - Learn web development | MDN
The first example is a box that has been restricted by setting a height . Then we add content that exceeds the allocated...
Read more >
Dropdown Height of Options | OutSystems
I am trying to find a way to limit the height of drop down by half. Actually a similar question came up and...
Read more >
What is the recommended height of a dropdown menu that ...
In your case make the dropdown occupy as much as you need (full-height with some margin below) so more options are visible without...
Read more >
Solution For Very Long Dropdown Menus - CSS-Tricks
jQuery Makes it Tick · Set a maximum height to the dropdowns · On hover, reveal the submenu · Calculate a speed multiplier...
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