Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-scroll is not triggered when inserting a block in long posts (only Android) #57586

Open
fluiddot opened this issue Jan 5, 2024 · 1 comment
Labels
Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) [Type] Bug An existing feature does not function as intended

Comments

@fluiddot
Copy link
Contributor

fluiddot commented Jan 5, 2024

Description

After the auto-scroll feature was added in #57273, on Android, it's not working in all cases. Specifically, if the post has several blocks, inserting a block in a far location from the current scroll position doesn't trigger it.

Step-by-step reproduction instructions

  1. Open the Android app.
  2. Create a post with several blocks (more than 85 blocks).
  3. Save the post.
  4. Re-open the post.
  5. Insert an Image block.
  6. Observe that content is not auto-scrolled to the insertion location of the Image block.

Expected behaviour

The auto-scroll should be triggered when inserting a block, independently of the post size.

Actual behaviour

The auto-scroll is not triggered in long posts.

Screenshots or screen recording (optional)

android-auto-scroll-long-post.mp4

WordPress information

  • WordPress version: N/A
  • Gutenberg version: N/A
  • Are all plugins except Gutenberg deactivated? N/A
  • Are you using a default theme (e.g. Twenty Twenty-One)? N/A

Device information

@fluiddot fluiddot added [Type] Bug An existing feature does not function as intended Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) labels Jan 5, 2024
@fluiddot
Copy link
Contributor Author

fluiddot commented Jan 5, 2024

This issue is related to the fact that on Android, the block list renders the blocks using the FlatList component. Specifically, we'd need to address the following problems:

We can't guarantee to have the layout of a block upon insertion due to virtualization

The approach we followed is based on the side effects produced in blocks, mainly because we need to retrieve the layout data of blocks to calculate the offset to scroll to upon insertion. Due to virtualization, a block inserted at the end of the post might be out of the visible window of the FlatList, hence it won't be created and all logic attached to it won't be executed.

Lack of getItemLayout implementation in FlatList

We tried moving the logic of the auto-scroll above the FlatList and detecting when a block will be inserted at the end. Since we don't have the layout data, as a workaround we can directly scroll to the end. However, the scroll doesn't reach the end because the height of the content view changes as the scroll goes down. Something similar happens when navigating to the top. This could be addressed by implementing the getItemLayout function in the FlatList. In fact, the lack of its implementation seems to impact negatively the experience when scrolling content. In any case, providing the functionality to enable getItemLayout comes with high complexity because requires to have a fixed size for blocks. Considering how dynamic the content of a post can be, maybe this approach won't be feasible and therefore, we'd need to come up with other alternatives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

1 participant