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

MPDX-7814 - Allow users to open contact in new tab #900

Closed
wants to merge 10 commits into from

Conversation

dr-bizz
Copy link
Contributor

@dr-bizz dr-bizz commented Mar 26, 2024

Description

https://jira.cru.org/secure/RapidBoard.jspa?rapidView=3&view=detail&selectedIssue=MPDX-7814#

Added a custom right-click menu, which for now only has the menu item Open contact in new tab.
But we could easily add quick actions to the right-click menu, making users make fewer clicks. One idea I had was for an open to allow the user to edit the contact details. which would open the contact details modal.
If users like the right-click, we could even use it on Tasks.

I also corrected some types in ContactContext

Checklist:

  • I have given my PR a title with the format "MPDX-(JIRA#) (summary sentence max 80 chars)"
  • I have applied the appropriate labels. (Add the label "On Staging" to get the branch automatically merged into staging.)
  • I have requested a review from another person on the project

@dr-bizz dr-bizz requested a review from canac March 26, 2024 15:45
Copy link
Contributor

Bundle Sizes

Compared against 5003e45

Route: No significant changes found

Dynamic import: None found.

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-900.d3dytjb8adxkk5.amplifyapp.com

Copy link
Contributor

@canac canac left a comment

Choose a reason for hiding this comment

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

I guess you couldn't get it to work by making the list items actual Next <Link>s and then letting the browser natively handle opening links in a new tab?

Is it hard to get the context menu to show up under the cursor instead of anchored to the left edge of the contact row?

@@ -153,4 +153,43 @@ describe('ContactsRow', () => {
userEvent.click(rowButton);
// TODO: Find a way to check that click event was pressed.
});

it('should NOT open menu on right-click', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this what you meant?

Suggested change
it('should NOT open menu on right-click', () => {
it('should NOT open menu on left-click', () => {

const rowButton = getByTestId('rowButton');
expect(queryByRole('menu')).not.toBeInTheDocument();
userEvent.click(rowButton);
expect(queryByRole('menu')).not.toBeInTheDocument();
Copy link
Contributor

Choose a reason for hiding this comment

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

In the other test, you are waiting for the menu to be visible. If the menu shows up asynchronously, then this test will pass even if the menu eventually shows up. Let's either remove the waitFor in the other test if that works or if not, add a waitFor to this test.

return (
<Menu
anchorEl={returnRightClickRef}
open={showMenu}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason this doesn't work? Then you could get rid of returnRightClickRef and remove the TypeScript cast.

Suggested change
open={showMenu}
anchorEl={rightClickRef.current}

const { getByRole, queryByRole } = render(<Components />);

const button = getByRole('button');
expect(button).toBeInTheDocument();
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you know that expect().toBeInTheDocument() is usually redundant? getByRole will fail the test if it isn't in the document. If you're just checking the existence of an element, I think it's fine to do expect().toBeInTheDocument(). But if you're interacting with an element (like clicking a button), I usually let the getByRole implicitly assert that the element exists and skipping the redundant .toBeInTheDocument() check. Feel free to disagree if you prefer the explicitness.


interface Props {
contactId: string;
rightClickRef: React.MutableRefObject<null>;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a name like menuAnchorRef would be more descriptive.

contactId: string;
rightClickRef: React.MutableRefObject<null>;
showMenu: boolean;
setShowMenu: React.Dispatch<React.SetStateAction<boolean>>;
Copy link
Contributor

Choose a reason for hiding this comment

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

This component only needs to hide the menu, it never needs to setShowMenu(true), so what if we make this prop onHideMenu instead of exposing the setter?

@dr-bizz
Copy link
Contributor Author

dr-bizz commented Mar 26, 2024

@canac There could be a lot of useful quick actions under the right-click menu that could help the contacts be more productive, which is why I did the right-click menu. As someone who doesn't use MPDx, I might be wrong, do you feel like this would benefit the user or will adding a NextLink be fine and users don't need quick actions?

If we use the right-click menu, it should show where you clicked. - I'll work on this.

@canac
Copy link
Contributor

canac commented Mar 27, 2024

do you feel like this would benefit the user or will adding a NextLink be fine and users don't need quick actions?

There's a lot of users of MPDX, so I'm sure some of them would find it useful. Personally, I'm more of a keyboard user, so shortcuts like Cmd+click to open in a new tab or keyboard shortcuts like "D" to open the contact details donations tab, "T" to open the contact details tasks tab, etc would speed up my workflow than a right-click menu. I'm probably in the minority though. I think most desktop users use the mouse a lot more than keyboard shortcuts.

@dr-bizz dr-bizz force-pushed the MPDX-7814-right-click-contacts branch from 1040bbd to c66e62b Compare April 12, 2024 21:11
Copy link
Contributor

Bundle sizes [mpdx-react]

Compared against 115b5ac

No significant changes found

@dr-bizz
Copy link
Contributor Author

dr-bizz commented Oct 30, 2024

I have pushed this code live in another PR #1090

@dr-bizz dr-bizz closed this Oct 30, 2024
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.

2 participants