Closed kelvinballoo closed 1 month ago
Thanks for the investigation and the IB here @techanvil. All LGTM.
IB :heavy_check_mark:
Verified good on real iPhone 15 Pro Max Safari. Ticket is good to move to approval.
The audiences is presented in the order described in https://github.com/google/site-kit-wp/issues/8519 at all times, both in the list of Audience Tiles and the Selection Panel. ✅
The audience tabs in the mobile, tabbed view functions without error when updating the audience selection in any way. ✅
In the tests "new visitors" always comes before "returning visitors". ✅
The "steps to reproduce" listed in the ticket description no longer result in errors. ✅
Audience ordering goes out of sync
Adding audience before the last tab breaks the new audience tab and the last tab
Removing audience does not select the remaining tab
Removing the first or second audience with three selected breaks the remaining tabs
Removing and readding an audience breaks the audience tab. Adding a third audience results in a JS error when clicking the tab.
Bug Description
A number of glitches have come to light in the Audience Tiles view. These should be looked at together as it's likely the fixes will be related.
Steps to reproduce
Audience ordering goes out of sync
Screen capture
https://github.com/user-attachments/assets/ddd75505-8e00-4b67-b50b-f53807f17fbeAlternatively:
Adding audience before the last tab breaks the new audience tab and the last tab
Screen capture
https://github.com/user-attachments/assets/369479fa-4102-422b-9b04-832fe7ff584dRemoving audience does not select the remaining tab
Screen capture
https://github.com/user-attachments/assets/fbda7830-fa25-44db-9102-a5407b34511bRemoving the first or second audience with three selected breaks the remaining tabs
Screen capture
https://github.com/user-attachments/assets/aad12d4e-a99b-4195-b44d-5f5e4efa7cf8Removing and readding an audience breaks the audience tab. Adding a third audience results in a JS error when clicking the tab.
Screen capture
https://github.com/user-attachments/assets/771d8a4f-e21a-4158-b5f0-abcdf110c93fNotes
Additional Context
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation Brief
Audience ordering
Analytics_4::set_available_audiences()
so that it defaults to the initial sort order if the order is otherwise equal, and sorts in the order "new audiences", "returning audiences" when theaudienceType
isSITE_KIT_AUDIENCE
.saveAudienceSettings()
action to order the saved audiences by their order inavailableAudiences
.Remember the previously active tab when the audience selection changes
AudienceTiles
component, store the active audience's name inactiveTile
rather than its index which can change when the audience selection is updated.activeTile
defaults to the first audience if the active audience is removed from the audience selection.TabBar glitches
The glitchy behaviour outside of the audience ordering is due to the
TabBar
implementation not handling updates to the tabs very well. This is because it maintains an internal list of tabs which it pushes to when it sees a new child element (seeref: this.pushToTabList
inrenderTab
), but doesn't reorder/update when the children are reordered or removed.We need to apply the following workarounds in the
AudienceTiles
component:visibleAudiences.length
to the renderedTabBar
. This ensures theTabBar
is rerendered when the number of audiences changes.index
instead ofaudienceResourceName
to the renderedTab
instances. This ensures the list of children will correspond to the internal tab list when the tabs are reordered.Draft PR
There is a draft PR that can be completed: https://github.com/google/site-kit-wp/pull/9228
Test Coverage
QA Brief
Changelog entry