Open techanvil opened 1 month ago
- An observable result of this is that the Selection Panels should not trigger any API requests upon page load, unless the request is explicitly determined to be required.
@techanvil if the goal is to ensure that no API requests are triggered when the selection panel is closed, then why not to just not render children?
@eugene-manuilov it's a fair question, and one I considered myself. However, as discussed here, I found it would cause a regression for slower machines as the panel would appear empty while it scrolls into view.
I found it would cause a regression for slower machines as the panel would appear empty while it scrolls into view
@techanvil, we can show a progress bar/preview block while data is being loaded, can't we? This is the standard pattern that we use for components that depends on data that loads on demand.
@eugene-manuilov, we do already show the Audience Selection Panel in a loading state, which is dynamic based on the current cached audience list and audience selection.
So, we've already got that aspect covered in the current implementation. We could restructure things so we have an explicitly defined "loading" component which we switch out for the loaded version when the panel is opened and the loaded state has been determined, but I think the proposed in-view approach would probably be easier to manage.
Ok, thanks, @techanvil. AC ✔️
Feature Description
Update the Audience and Metric Selection Panels to be in-view aware, and update them to use the
useInViewSelect()
hook in place ofuseSelect()
for any selectors which use a resolver or result in a resolver firing via another selector.This is a followup to 8879, see the comments on that issue for more context: https://github.com/google/site-kit-wp/issues/8879#issuecomment-2332401260
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
SelectionPanel
component should wrap its children in anInViewProvider
whose in-view state is determined by the open state of the panel.useInViewSelect()
hook in place ofuseSelect()
for any selectors which use a resolver or result in a resolver firing via another selector.Implementation Brief
assets/js/components/SelectionPanel/SelectionPanel.js
, importingInViewProvider
and wrapping{ children }
in this component, passingisOpen
to thevalue
prop.Key Metrics Selection Panel
useSelect
's to useuseInViewSelect
: from within this selection panel and it's children:Audience Segmentation Panel
useSelect
's to useuseInViewSelect
: from within this selection panel and it's children:Test Coverage
QA Brief
Changelog entry