-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
This pull request is automatically being deployed by Amplify Hosting (learn more). |
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? |
There was a problem hiding this 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, |
There was a problem hiding this comment.
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?
@canac yeah it is a bit messy. I was trying to go with what was there already, so I didn't have to provide |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<ContactsProvider | ||
urlFilters={{}} | ||
activeFilters={{}} | ||
setActiveFilters={() => {}} | ||
starredFilter={{}} | ||
setStarredFilter={() => {}} | ||
filterPanelOpen={false} | ||
setFilterPanelOpen={() => {}} | ||
contactId={[]} | ||
searchTerm={'test'} | ||
> |
There was a problem hiding this comment.
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 }}
>
There was a problem hiding this comment.
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.
@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. |
There was a problem hiding this 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.
src/components/Contacts/MassActions/Merge/MassActionsMergeModal.test.tsx
Outdated
Show resolved
Hide resolved
src/components/Contacts/MassActions/Merge/MassActionsMergeModal.test.tsx
Outdated
Show resolved
Hide resolved
src/components/Shared/MassActions/ContactsMassActionsDropdown.test.tsx
Outdated
Show resolved
Hide resolved
src/components/Contacts/MassActions/Merge/MassActionsMergeModal.test.tsx
Outdated
Show resolved
Hide resolved
src/components/Contacts/MassActions/Merge/MassActionsMergeModal.test.tsx
Outdated
Show resolved
Hide resolved
describe('ExportModal', () => { | ||
it('should render modal', () => { | ||
const { getByText } = render( | ||
const MassActionsMergeModalWrapper: React.FC< |
There was a problem hiding this comment.
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?
There was a problem hiding this 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; | |||
|
There was a problem hiding this comment.
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', () => { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
7805e44
to
9055182
Compare
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: