Skip to content

fix: Scrolling along edges breaks text editing#135

Merged
dcalhoun merged 1 commit intotrunkfrom
fix/scrolling-edges-breaks-text-editing
May 19, 2025
Merged

fix: Scrolling along edges breaks text editing#135
dcalhoun merged 1 commit intotrunkfrom
fix/scrolling-edges-breaks-text-editing

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