Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d5aca35

Browse files
authoredMay 19, 2025··
fix: Scrolling along edges breaks text editing (#135)
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.
1 parent 1b19fef commit d5aca35

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
 
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/node_modules/@wordpress/rich-text/build-module/component/event-listeners/prevent-focus-capture.js b/node_modules/@wordpress/rich-text/build-module/component/event-listeners/prevent-focus-capture.js
2+
index 3b885f5..c2ea3d0 100644
3+
--- a/node_modules/@wordpress/rich-text/build-module/component/event-listeners/prevent-focus-capture.js
4+
+++ b/node_modules/@wordpress/rich-text/build-module/component/event-listeners/prevent-focus-capture.js
5+
@@ -36,9 +36,11 @@ export function preventFocusCapture() {
6+
}
7+
defaultView.addEventListener('pointerdown', onPointerDown);
8+
defaultView.addEventListener('pointerup', onPointerUp);
9+
+ defaultView.addEventListener('pointercancel', onPointerUp);
10+
return () => {
11+
defaultView.removeEventListener('pointerdown', onPointerDown);
12+
defaultView.removeEventListener('pointerup', onPointerUp);
13+
+ defaultView.removeEventListener('pointercancel', onPointerUp);
14+
};
15+
};
16+
}

‎patches/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ Existing patches should be described and justified here.
1010

1111
- Expose an `open` prop on the `Inserter` component, allowing toggling the inserter visibility via the quick inserter's "Browse all" button.
1212
- Disable `stripExperimentalSettings` in the `BlockEditorProvider` component so that the Patterns and Media inserter tabs function.
13+
14+
### `@wordpress/rich-text`
15+
16+
- Fix `preventFocusCapture` causing uneditable text blocks on touch devices when scrolling by swiping outside of the block canvas--e.g., along the edge of the screen.

0 commit comments

Comments
 (0)
Please sign in to comment.