8000 Refactor MXContextMenu by walesch-yan · Pull Request #1626 · mxcube/mxcubeweb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Refactor MXContextMenu #1626

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

Merged
merged 1 commit into from
Apr 15, 2025
Merged

Refactor MXContextMenu #1626

merged 1 commit into from
Apr 15, 2025

Conversation

walesch-yan
Copy link
Collaborator

This PR refactors the MXContextMenu into a functional component and replaces the .css file with a module.

2 minor changes:

  • I removed the closing animation, as it was called directly with the change to the show attribute, which meant that the element disappeared before the animation was playing anyways.
  • There was a check in x direction so that the context menu would overflow. I added a check in y-direction which means less scrolling when selecting a context menu for samples displayed at the bottom of the screen

@walesch-yan walesch-yan force-pushed the yw-refactor-MXContextMenu branch from 0dc8719 to a23b666 Compare April 14, 2025 11:21
Copy link
Collaborator
@axelboc axelboc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

if (ctxMenu) {
ctxMenu.classList.add('generic-context-menu-close');
useEffect(() => {
function hideContextMenu() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth investigating the use of Bootstrap's Overlay, which has a rootClose prop to deal with hiding on click anywhere else. Anyway, not for this PR, it's more FYI in the broader scope of merging together the various context menu implementations present in the codebase.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting didn't know about that, I will definitely check that out thanks!


export default function MXContextMenu(props) {
const { children } = props;
const contextMenu = useSelector(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would destructure this, maybe on a separate line, and then list the specific variables needed in the useEffect dependencies array.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I will update:)

@walesch-yan walesch-yan force-pushed the yw-refactor-MXContextMenu branch from a23b666 to 39789da Compare April 14, 2025 11:49
@walesch-yan walesch-yan force-pushed the yw-refactor-MXContextMenu branch from 39789da to ac70e04 Compare April 14, 2025 12:09
@marcus-oscarsson marcus-oscarsson merged commit 02d18fe into develop Apr 15, 2025
17 checks passed
@marcus-oscarsson marcus-oscarsson deleted the yw-refactor-MXContextMenu branch April 15, 2025 07:26
Copy link
Member
@jbflo jbflo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bit late but i think we need to check the Context menu position when the page scroll. that was the specificity of the MXContextMenu : be able to track the mouse click position when the page scroll .


let posxoffset = 10;
if (menuEndPos > windowWidth) {
posxoffset = contextMenu.offsetWidth;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@walesch-yan sorry a bit late
i think this PR introduce a regression
the context menu lost it's click position when the page is scroll

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. The idea was to replace the menu inside the viewable window (in y-direction) to prevent scrolling, but it is missing the value of the offset from the top of the page (I.e. when scrolling down a little, it will always pop up on top as we are below the the windowheight offset).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will make a new PR to fix this

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing it out!:)

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
0