Skip to content

fix: Scrolling along edges breaks text editing #135

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

Merged
merged 1 commit into from
May 19, 2025

Conversation

dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented May 16, 2025

What?

Fix perpetually disabled text blocks after scrolling the editor by swiping
outside of the block canvas container.

Why?

Fix CMM-356. The inability to edit text is unexpected.

How?

Existing Gutenberg preventFocusCapture logic relies upon pointerdown
and pointerup events for temporarily disabling all text blocks
contenteditable status. This is done to mitigate issues with block
selection for flex elements.

However, pointerup events are not always triggered on touch devices
when a touch turns into a swipe. When you scroll with your finger
outside of the block canvas, the pointerup callback is never invoked.
Scrolling twice or more leads to a stale value in the callback, and a
state where contenteditable is perpetually disabled.

Testing Instructions

  1. Open a post with a few text blocks.
  2. Scroll by swiping alongside the edge of the display—i.e., outside of the
    block canvas that contains the blocks.
  3. Perform the previous step at least once more.
  4. Attempt to focus a text block and modify its content.

Accessibility Testing Instructions

N/A, no navigation changes.

Screenshots or screencast

N/A, no visual changes.

Existing Gutenberg `preventFocusCapture` logic relies upon `pointerdown`
and `pointerup` events for temporarily disabling all text blocks
`contenteditable` status. This is down to mitigate issues with block
selection for `flex` elements.

However, `pointerup` events are not always triggered on touch devices
when a touch turns into a swipe. When you scroll with your finger
outside of the block canvas, the `pointerup` callback is never invoked.
Scrolling twice or more leads to a stale `value` in the callback, and a
state where `contenteditable` is perpetually disabled.
@dcalhoun dcalhoun added the [Type] Bug An existing feature does not function as intended label May 16, 2025
@dcalhoun dcalhoun marked this pull request as ready for review May 16, 2025 19:57
@dcalhoun dcalhoun requested a review from nbradbury May 16, 2025 19:57
@nbradbury nbradbury self-assigned this May 19, 2025
Copy link
Contributor

@nbradbury nbradbury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix is good! I was able to reproduce the problem in trunk but not with this branch :shipit:

@dcalhoun dcalhoun merged commit d5aca35 into trunk May 19, 2025
11 checks passed
@dcalhoun dcalhoun deleted the fix/scrolling-edges-breaks-text-editing branch May 19, 2025 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants