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 Album context menu moves behind adjacent album entries #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Yi-Wang126
Copy link
Collaborator

@Yi-Wang126 Yi-Wang126 commented Oct 16, 2024

Description

This PR addresses the implementation of a context menu for the Card component, as discussed in Issue 1673. The new functionality allows users to interact with the card via a dropdown menu that appears upon hover, improving usability and accessibility.

Changes Made

  1. Added Context Menu Functionality:

    • Introduced a state management system to handle the visibility of the context menu on mouse enter and leave events.
    • Utilized ReactDOM.createPortal to render the dropdown menu outside the card’s DOM hierarchy for better positioning.
  2. Dynamic Menu Positioning:

    • Implemented a position update mechanism to ensure the dropdown appears correctly relative to the card.
    • Used MutationObserver and ResizeObserver for dynamic adjustments to the menu's position.
  3. Styling Adjustments:

    • Updated CSS to include a placeholder for the menu button to maintain layout integrity during hover events.
    • Ensured the menu is styled to overlay on top of the card and remains responsive to various screen sizes.

    Screenshots

Before Changes:
image
After Changes:
image

@onamdumbare
Copy link
Collaborator

As can be seen in the below image the remove option for the right side track has been cut off. Need to fix it.

image

@u7630748
Copy link
Owner

I found another bug :octocat:
The menu only shows up when we point to the album card:
image

If the mouse didn't point to the album card, it disappeared:
image

Second thing: the code seems didn't run linter to format it.

@Siyi-Liu42
Copy link
Collaborator

Siyi-Liu42 commented Oct 16, 2024

image image

Hi,
I added the necessary test code, modified the JSON file, and ran npm run lint:fix to ensure code consistency.

@Yi-Wang126
Copy link
Collaborator Author

I found another bug :octocat: The menu only shows up when we point to the album card: image

If the mouse didn't point to the album card, it disappeared: image

Second thing: the code seems didn't run linter to format it.

Can u guys have a try to solve these bugs, I have already tried to solve it, but it didn't work……

@Siyi-Liu42
Copy link
Collaborator

Hi, I attempted to replace the Dropdown component with a Popup containing a Menu, following the idea that Dropdown doesn’t natively support rendering the menu in a portal.

Here’s what I tried:

  • I used popper={{ positionFixed: true }} to render the popup inside a portal.
  • Adjusted the menu entries to use Menu components instead of Dropdown components for better control.

However, despite these changes, I encountered issues. The main problem was a large white box surrounding the Remove menu item, which I couldn’t resolve. Additionally, aligning the Popup properly was tricky, and I couldn’t get the behavior I wanted. Sad for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants