Prevent Selection Panel Info Notice from disappearing until two audiences are selected
Feature Description
In its initial implementation, the Selection Panel Info Notice will disappear when the user opens the Selection Panel with a single selected audience, and unchecks that audience.
This is not ideal, as the notice is intended to encourage the user to add a second audience to the selection, so it would be better to keep the notice visible until they have at least two audiences selected.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The Selection Panel Info Notice should only appear when the Selection Panel is opened with a single saved audience in the selection (this is as per the initial implementation).
- The notice should remain visible until at least two audiences are selected. It should not reappear if the user reduces the selection to a single audience while the selection panel remains open.
- Once two audiences are selected the notice should disappear.
Implementation Brief
- [ ] Within
assets/js/modules/analytics-4/components/audience-segmentation/dashboard/AudienceSelectionPanel/AddGroupNotice.js:- [ ] Replace the
selectionChangesconst, instead use thegetValueselector to get the selected audiences passingAUDIENCE_SELECTION_FORM, AUDIENCE_SELECTED- this will return the list of currently selected audiences - call thisselectedAudiences. - [ ] Create a new
useStatecalledtwoOrMoreAudiencesSelecteddefaulting tofalse. - [ ] Create a
useEffectwatching changes onselectedAudiences:- [ ] If
selectedAudiencesis not an array, return early. - [ ] If
selectedAudiences.length > 1, settwoOrMoreAudiencesSelected= true
- [ ] If
- [ ] Update the if statement that returns null to be:
isDismissed || twoOrMoreAudiencesSelected.
- [ ] Replace the
- [ ] Remove the now unused
AUDIENCE_SELECTION_CHANGEDform key and everywhere it's used/updated.
Test Coverage
- No additional test are required.
QA Brief
Changelog entry
@techanvil Just to quickly confirm, what happens if the user unselects one of the audiences after they've selected two? Should the notice reappear? If not, the IB will need to be updated to address that behaviour. I'll write my IBR feedback based on your response, thank you!
Thanks @nfmohit - I should have been more explicit in the AC. The not should indeed not reappear - I've updated the AC accordingly.
Thank you for the confirmation and amendment, @techanvil !
@benbowler Thank you for the IB. Let's update it to make sure the notice doesn't reappear when the user reduces their selection to one audience. We may be able to use a local state in conjunction with a useEffect to achieve this behaviour.
Also, could you also instruct to remove the AUDIENCE_SELECTED form key if it is no longer needed? It was only added for this component as far as I know.
Thank you for the update, @benbowler . I think 3 as an estimate is quite steep here just in case an unexpected side-effect comes up. Do you think it might be worth increasing it by a notch just so we're safe?
Good point, updated @nfmohit
Thanks @benbowler ! IB LGTM 👍 ✅
QA Update ✅
- Tested on main environment.
- Verified The Selection Panel Info Notice s appear only when the Selection Panel is opened with a single saved audience in the selection (this is as per the initial implementation).
- The notice remain visible until at least two audiences are selected. It not reappear if the user reduces the selection to a single audience while the selection panel remains open.
- Verified Once two audiences are selected the notice gets disappear.
- Verified If one is deselected again - notice not appear immediately, but only on the next opening.
https://github.com/user-attachments/assets/1be72273-4503-4d4f-9344-e18de10b295a