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.

Menu position calculation incorrect when attached to custom element

See original GitHub issue

I have a fullscreen dialog with some selects and other elements which use detachable components, e.g. v-menu. When the dialog needs to scroll it cause problem because the menu is attached to the root by default so it does not scroll with the select list. I tried to set the attach property on v-select to the .v-dialog element but in this case the position of the menu is not calculated correctly (it always gets top/left: 0).

Versions and Environment

Vuetify: Latest Vue: Latest stable Browsers: Chrome latest OS: Win7

Steps to reproduce

Click on Open Dialog and then open the select menu.

Expected Behavior

The menu should appear in the correct position.

Actual Behavior

The menu always appears in the top left corner.

Reproduction Link

Go to https://codepen.io/anon/pen/PBwpZz


Additional Comments:

If I set the attach prop to some non-existing element it sort of works because it seems then that the menu content is attached to the immediate parent, but still the position is not correct and this is an ugly workaround.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
Tofandelcommented, Jul 4, 2020

IMO the calculation for the position of the dropdown is invalid and buggy… It should find the first parent of the element to which it is attached and calculate it’s position relative to that element… Right now it wrongly assumes the v-app should be at a position of 0,0 on the page at all time, so if the v-app is contained in something it will calculate the position relative to the document instead of the v-app, so you will have a double offset effect and the dropdown will be far far away from where it should be…

Also you don’t always have control on the component props in libraries or other element that use a dropdown, resulting in a lot of invalid positioning that cannot be fixed…

This default behavior should be changed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Positioning Context Menu - javascript - Stack Overflow
The problem is that when you right click then left click elsewhere and then right click again, the position is incorrect.
Read more >
Positioning - Learn web development | MDN
Positioning allows you to take elements out of normal document flow and make them behave differently, for example, by sitting on top of...
Read more >
Building Accessible Menu Systems - Smashing Magazine
In design, we often make the same mistake of giving different things the same name. They appear similar, but appearances can be deceptive....
Read more >
Building a Custom Right-Click (Context) Menu with JavaScript
In this tutorial, we're going to cover a few things: Define what a context menu actually is, and understand its purpose and position...
Read more >
Resolve common errors for Dashboard Components
If the source report of the dashboard's component is in Summary format, ... One example is that the Custom Summary Formula is referencing...
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