List View: Stale windowing logic when switching between content and template in site editor when no content block is present #56360
Labels
[Feature] List View
Menu item in the top toolbar to select blocks from a list of links.
[Priority] Low
Used to indicate that the issue at hand isn't a top priority to address and can be handled later
[Type] Bug
An existing feature does not function as intended
Description
This issue is pretty edge-casey (and therefore low priority), but I noticed it while testing out #56326. When switching between the content only and template editing modes in the site editor (while viewing a particular page of a site), there's nothing that explicitly tells the windowing logic for the list view to update.
This means that in a page whose template does not include a Content block, if we switch to the template mode, and that template has a large number of blocks (enough to usually trigger the windowing logic), then it's possible to get into a state where scrolling the template does not update the windowing, and a user cannot see the items in the list.
It turns out the likely culprit is that when a template does not contain any content blocks, then switching between the content only or template modes does not update the
getGlobalBlockCount
used to calculatevisibleBlockCount
for the list view's windowing logic, and that value is used to figure out when to refresh the windowing logic.To resolve this (likely low priority issue) I believe we'll want to inspect
clientIdsTree
which is returned byuseListViewClientIds
and use a change to that tree as an indicator that the windowing logic should be updated. We might want to be careful doing that, though, that we don't look at the value too frequently, for performance concerns.Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
In the below screengrab, we first load a page in the site editor which is using a template that does not contain a Content block. In this example, we assume a user might be intending to go to the template in order to add the block somewhere. However, after switching to the template mode, the list view does not update to reflect the windowing logic that should be used. (Note that if a user expands or collapses any blocks, the windowing logic will update):
2023-11-21.16.43.11.mp4
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: