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-7852] -clear contact selection after merge #885

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

wjames111
Copy link
Contributor

@wjames111 wjames111 commented Mar 4, 2024

Description

Jira ticket #7852. After a successful contact merge, we need to clear the checkboxes. Currently, it keeps the checkboxes checked, causing people to merge multiple contacts if they aren't paying close attention to the prompts (It is easy to miss).

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

@wjames111 wjames111 changed the title 7852 merge clear contacts [MPDX-7852] -clear contact selection after merge Mar 4, 2024
@wjames111 wjames111 self-assigned this Mar 4, 2024
@wjames111 wjames111 added the On Staging Will be merged to the staging branch by Github Actions label Mar 4, 2024
Copy link

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

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

@canac
Copy link
Contributor

canac commented Mar 4, 2024

Instead of deselecting everything, I wonder if we should have the mass actions modal tell the context which ids were the losers of the merge and don't exist anymore, and just deselecting those contacts?

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.

The code seems to work as intented! I think you should either add the deselect all to the context (that's what I'd recommend) or prop drill but not both.

@@ -37,6 +38,7 @@ export const ContactsMassActionsDropdown: React.FC<
contactsView,
buttonGroup,
selectedIds,
massDeselectAll,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't you get the deselect all method from <ContactsContext> instead of prop drilling?

@wjames111
Copy link
Contributor Author

@canac yeah it is a bit messy. I was trying to go with what was there already, so I didn't have to provide <ContactsContext> to another component, but the end result ends up being confusing. I'll update it to just use <ContactsContext> directly. I couldn't think of an instance where clearing all would be a bad thing but I like the idea of just deselecting the winner after merge. It's cleaner that way.

@dr-bizz
Copy link
Contributor

dr-bizz commented Mar 5, 2024

@canac

Instead of deselecting everything, I wonder if we should have the mass actions modal tell the context which ids were the losers of the merge and don't exist anymore, and just deselecting those contacts?

Is this wise? The original task mentions that after doing a successful merge, some users would do another merge but since the first contact(s) are still selected, they would merge that contact too. (I had a few Helpscout tickets about this.)

I think it's best to deselect all contacts after a successful merge, if the user wants to select that contact again, they can.
Also, the only contact that will be selected after a successful merge will be the winner. massDeselectAll or toggleSelectionById I don't see the difference.

Copy link
Contributor

@dr-bizz dr-bizz left a comment

Choose a reason for hiding this comment

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

Great work on this. I mentioned a few things in a comment above and one place we need to add a test. But apart from that it's looking great.

I did see when testing, that the select all checkbox still thinks something is checked after a successful merge.

Screenshot 2024-03-05 at 8 52 54 AM

Comment on lines 274 to 273
<ContactsProvider
urlFilters={{}}
activeFilters={{}}
setActiveFilters={() => {}}
starredFilter={{}}
setStarredFilter={() => {}}
filterPanelOpen={false}
setFilterPanelOpen={() => {}}
contactId={[]}
searchTerm={'test'}
>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you test that toggleSelectionById is run after a successful merge? I believe you can do it using the below.

const toggleSelectionById = jest.fn()
<ContactsProvider
      value={{ toggleSelectionById }}
    >

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing! thanks for the snippet, I was struggling to figure out how to use useContext in a test.

@canac
Copy link
Contributor

canac commented Mar 5, 2024

Is this wise? The original task mentions that after doing a successful merge, some users would do another merge but since the first contact(s) are still selected, they would merge that contact too. (I had a few Helpscout tickets about this.)

@dr-bizz That's valid. Sorry, I didn't read the ticket super closely. My intuition is that the contact would stay selected, but I can also see how that could be confusing to some users.

@wjames111 You can disregard my original comment.

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.

It works well locally for me! Left a few style suggestions.

describe('ExportModal', () => {
it('should render modal', () => {
const { getByText } = render(
const MassActionsMergeModalWrapper: React.FC<
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move this outside of the describe block?

Copy link
Contributor

@dr-bizz dr-bizz left a comment

Choose a reason for hiding this comment

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

Everything looks great! I left a few comments, but nothing major. You may feel like you don't need to change anything, so I approved it.

@@ -41,6 +45,8 @@ export const MassActionsMergeModal: React.FC<MassActionsMergeModalProps> = ({
accountListId,
ids,
}) => {
const { deselectAll } = useContext(ContactsContext) as ContactsType;

Copy link
Contributor

Choose a reason for hiding this comment

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

You could remove this empty line

);
};

describe('ExportModal', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the name of this be MassActionsMergeModal?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I think it should be, keep with the naming conventions.

@wjames111 wjames111 force-pushed the 7852-merge-clear-contacts branch from 7805e44 to 9055182 Compare March 19, 2024 20:37
@wjames111 wjames111 merged commit 3c9d19c into main Mar 19, 2024
18 checks passed
@wjames111 wjames111 deleted the 7852-merge-clear-contacts branch March 19, 2024 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
On Staging Will be merged to the staging branch by Github Actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants