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

dropdown goes off-screen #112

Closed
gluck opened this issue Jun 21, 2022 · 7 comments
Closed

dropdown goes off-screen #112

gluck opened this issue Jun 21, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@gluck
Copy link

gluck commented Jun 21, 2022

Since I upgraded to latest/v2 (from 1.8.4), dropdown menus are painted off screen when the dropdown is near the top of the page.

Can be reproduced by removing layout: 'centered' in storybook (or removing the corresponding class as I do in the GIF below), the first options are no longer visible.

dropdown

@yuanqing yuanqing added the bug Something isn't working label Jun 21, 2022
@yuanqing
Copy link
Owner

Thanks for reporting. Am able to reproduce this. This seems to happen only when the dropdown has no value set when it is clicked

@yuanqing
Copy link
Owner

@gluck – I rewrote much of the menu sizing/positioning logic and released the fix in 2.1.1-alpha.0

@gluck
Copy link
Author

gluck commented Jun 23, 2022

Still getting bad display:
image

I'm getting negative values for:

  • maximumTopOffset: -16
  • minimumTopOffset: -1013

Then top gets set to --16px (which doesn't do anything)

I believe proper values for min/max offsets should be:

  const minimumTopOffset = Math.min(
    0,
    rootElementBoundingClientRect.top
  ); // menu should at least be displayed over the dropdown, not below
  const maximumTopOffset = Math.max(
    0,
    rootElementBoundingClientRect.top - VIEWPORT_MARGIN
  ); // menu shouldn't go off screen

(should also ensure non-negative, but still sign invert should be done in number, not in string)

gluck added a commit to divriots/create-figma-plugin-ui that referenced this issue Jun 23, 2022
gluck added a commit to divriots/create-figma-plugin-ui that referenced this issue Jun 23, 2022
yuanqing/create-figma-plugin#112

Co-authored-by: Francois Valdy <604263+undefined@users.noreply.github.com>
@yuanqing
Copy link
Owner

Thanks for testing this! The version I shipped in 2.1.1-alpha.0 doesn’t properly account for VIEWPORT_MARGIN. I’ve just managed to figure out the correct algorithm

@bashmish
Copy link

bashmish commented Jul 5, 2022

Since you are working on the fix for this algorithm, maybe good to report another aspect of this issue (let me know if you prefer making a new issue).

When the component is rendered within a container with overflow: hidden, which is quite a common case for us due to the need to add scrollbars, we get it clipped too. The reproduction in the storybook might look like this (I manually added overflow: hidden on div.root):

image

I assume it's because of the usage of a combination of position: relative on the dropdown container and position: absolute on the dropdown itself.

To support a use-case with overflow: hidden container this algorithm might require more refactoring.

@yuanqing
Copy link
Owner

Original bug should be fixed as of 2.1.1 (see Storybook). Created a new issue (#117) for the bug reported by @bashmish

@sholzmayer
Copy link

sholzmayer commented Mar 11, 2023

The issue still exists, when you have a separator included and place the menu to the top.

[
  { value: "Text Extender" },
  { separator: true },  // https://github.com/yuanqing/create-figma-plugin/issues/112
  { value: "Hero Texts" },
  { value: "Features" },
  { value: "Pricing Cards" },
]

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants