Components: withAPIData: Populate cached data for initial render #3058
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request seeks to improve the behavior of the
withAPIData
higher-order component to make data available during an initial render if a cached response is already available. Previously, even if the cache value was to become immediately available after mount, it would occur on an update after the initial mount. The changes here not only save a render in these cases, but it also seeks to resolve an issue where the publish dropdown menu doesn't initially focus tabbables within the dropdown menu because capabilities weren't yet known at the time.Testing instructions:
Ensure unit tests pass:
Verify that there are no regressions in API data behavior, either in cases where data is fetched fresh (e.g. authors) or prepopulated (current user publish permissions).
Verify that the first tabbable panel in the publish menu becomes focused when the menu is opened. See #3057 for more context on whether we want this to occur on click behaviors.