site-kit-wp icon indicating copy to clipboard operation
site-kit-wp copied to clipboard

Prevent Selection Panel Info Notice from disappearing until two audiences are selected

Open techanvil opened this issue 1 year ago • 6 comments

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 selectionChanges const, instead use the getValue selector to get the selected audiences passing AUDIENCE_SELECTION_FORM, AUDIENCE_SELECTED - this will return the list of currently selected audiences - call this selectedAudiences.
    • [ ] Create a new useState called twoOrMoreAudiencesSelected defaulting to false.
    • [ ] Create a useEffect watching changes on selectedAudiences:
      • [ ] If selectedAudiences is not an array, return early.
      • [ ] If selectedAudiences.length > 1, set twoOrMoreAudiencesSelected = true
    • [ ] Update the if statement that returns null to be: isDismissed || twoOrMoreAudiencesSelected.
  • [ ] Remove the now unused AUDIENCE_SELECTION_CHANGED form key and everywhere it's used/updated.

Test Coverage

  • No additional test are required.

QA Brief

Changelog entry

techanvil avatar Jun 19 '24 15:06 techanvil

@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!

nfmohit avatar Jun 24 '24 22:06 nfmohit

Thanks @nfmohit - I should have been more explicit in the AC. The not should indeed not reappear - I've updated the AC accordingly.

techanvil avatar Jun 25 '24 08:06 techanvil

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.

nfmohit avatar Jun 25 '24 08:06 nfmohit

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?

nfmohit avatar Jun 26 '24 20:06 nfmohit

Good point, updated @nfmohit

benbowler avatar Jun 27 '24 08:06 benbowler

Thanks @benbowler ! IB LGTM 👍 ✅

nfmohit avatar Jun 30 '24 01:06 nfmohit

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

mohitwp avatar Aug 07 '24 11:08 mohitwp