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

Fix DesktopDropdownMenuPositionProvider to align with the correct horizontal side of the window #555

Merged
merged 2 commits into from May 11, 2023

Conversation

m-sasha
Copy link

@m-sasha m-sasha commented May 9, 2023

DesktopDropdownMenuPositionProvider currently implements a discontinuous choice for horizontally positioning the dropdown relative to its anchor. Specifically, if the desired horizontal position (aligned with the left of the anchor) doesn't fit in the screen, it will align the dropdown with the right of the window. This is wrong if the reason it doesn't fit is because the anchor is at negative coordinates.

Proposed Changes

Fix DesktopDropdownMenuPositionProvider to provide a continuous function when positioning the dropdown horizontally:

  • If the desired position is at negative coordinates, align it with the left of the window.
  • If the desired position places the right side of the dropdown outside the window, align it with the right of the window.

Also take into account the option of RTL layout, where the preferred position is to align the dropdown with the right of the anchor.

Testing

Test: Added a few new unit tests.

Issues Fixed

Fixes: JetBrains/compose-multiplatform#3129

@m-sasha m-sasha requested a review from MatkovIvan May 9, 2023 10:13
@m-sasha m-sasha force-pushed the m-sasha/dropdown-menu-positioning branch from 044d286 to 3afd661 Compare May 9, 2023 16:45
@m-sasha m-sasha force-pushed the m-sasha/dropdown-menu-positioning branch from 536f951 to 0fdcc83 Compare May 11, 2023 13:10
@m-sasha m-sasha merged commit 9520c6e into jb-main May 11, 2023
1 of 2 checks passed
@m-sasha m-sasha deleted the m-sasha/dropdown-menu-positioning branch May 11, 2023 14:00
igordmn pushed a commit that referenced this pull request Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants