Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve connected overlay positioning #418

Closed
nestorrente opened this issue Aug 1, 2020 · 1 comment
Closed

Improve connected overlay positioning #418

nestorrente opened this issue Aug 1, 2020 · 1 comment
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@nestorrente
Copy link
Contributor

When using appendTo="body", dropdown's option list overflows the viewport's width if the element is near to the right side of the screen, even if there is enough space to display the list:

image

You can see it in action here: https://codesandbox.io/s/hardcore-satoshi-xz465?file=/src/components/HelloWorld.vue

I think the problem is at this line of DomHandler:

if (targetOffset.left + targetOuterWidth + elementOuterWidth > viewport.width)

The current condition is:
targetOffset.left + targetOuterWidth + elementOuterWidth > viewport.width

which I think is not right, because it is adding both the target and the element width. I think the right condition would be:
targetOffset.left + elementOuterWidth > viewport.width

With this change, the result is:
image

Do you see any issues with doing that change?

@cagataycivici cagataycivici self-assigned this Aug 4, 2020
@cagataycivici cagataycivici changed the title Dropdown's options list overflows viewport when using appendTo="body" Improve connected overlay positioning Aug 4, 2020
@cagataycivici cagataycivici added this to the 2.0.6 milestone Aug 4, 2020
@cagataycivici cagataycivici added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Aug 4, 2020
@cagataycivici
Copy link
Member

I've ported the algorithm we use in PrimeNG which is more mature and proven to be more precise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

No branches or pull requests

2 participants