Skip to content

fix: Mitigate GutenbergKit text composition oddities #21883

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

Open
wants to merge 7 commits into
base: trunk
Choose a base branch
from

Conversation

dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented May 15, 2025

Description

Fix CMM-353. Fix CMM-199.

Mitigate text composition oddities where editor history was lost and the inline
block inserter erroneously dismissed.

Related:

Testing instructions

Important

A bug remains present for Samsung keyboard users where the inline inserter does not update its filtering until text composition ends—adding a space, tapping a word in the toolbar, etc.

1: History stack functions as expected
See: wordpress-mobile/GutenbergKit#130

2: Inline inserter does not prematurely dismiss
See: wordpress-mobile/GutenbergKit#103

3: Save on exist includes latest typed content for devices using Samsung keyboard with predictive text

  1. Use a Samsung device.
  2. Ensure the Samsung keyboard is used and "predictive text" is enabled in the settings.
  3. Type a few words into a paragraph in a post.
  4. Do not type a space after the last word, confirm the last word via the keyboard toolbar, blur the text input, or take any other action that "confirms" the last word.
  5. Tap the back button to exit the editor.
  6. Verify the last (unconfirmed and/or pending text composition) word in the post was saved.

4: Smoke test the Gutenberg Mobile (GBM) and Aztec editors
For GBM: Disable the experimental editor.
For Aztec: P9ugOq-4rN-p2

dcalhoun added 4 commits May 15, 2025 14:33
Forcibly ending text composition led to odd outcomes--e.g., erroneously
dismissing the inline inserter, resetting editor history stack.

It was originally added to ensure the latest text in the editor is
captured before providing it to the host app for persistence. This
appears necessary for Samsung device keyboards only. For the time being,
text may be lost on these devices if the user does not first blur the
text input before saving or exiting the editor.
Ensure the latest text is captured before attempting to persist the post
content.
The rest of the editor methods throw this exception.
@dcalhoun dcalhoun added [Type] Bug Gutenberg Editing and display of Gutenberg blocks. labels May 15, 2025
@dangermattic
Copy link
Collaborator

dangermattic commented May 15, 2025

1 Warning
⚠️ PR is not assigned to a milestone.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Contributor

Project dependencies changes

list
! Upgraded Dependencies
org.wordpress.gutenbergkit:android:134-9ddb18e52f80387559ae1bcde7c59a3657b93212, (changed from trunk-fdfe788530bbff864ce7147b5a68608d7025e078)
tree
 +--- project :libs:editor
-|    \--- org.wordpress.gutenbergkit:android:trunk-fdfe788530bbff864ce7147b5a68608d7025e078
+|    \--- org.wordpress.gutenbergkit:android:134-9ddb18e52f80387559ae1bcde7c59a3657b93212
-\--- org.wordpress.gutenbergkit:android:trunk-fdfe788530bbff864ce7147b5a68608d7025e078 (*)
+\--- org.wordpress.gutenbergkit:android:134-9ddb18e52f80387559ae1bcde7c59a3657b93212 (*)

@wpmobilebot
Copy link
Contributor

wpmobilebot commented May 15, 2025

Jetpack📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack Jetpack
FlavorJalapeno
Build TypeDebug
Versionpr21883-a936fc0
Commita936fc0
Direct Downloadjetpack-prototype-build-pr21883-a936fc0.apk
Note: Google Login is not supported on these builds.

@wpmobilebot
Copy link
Contributor

wpmobilebot commented May 15, 2025

WordPress📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress WordPress
FlavorJalapeno
Build TypeDebug
Versionpr21883-a936fc0
Commita936fc0
Direct Downloadwordpress-prototype-build-pr21883-a936fc0.apk
Note: Google Login is not supported on these builds.

Copy link

codecov bot commented May 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 39.58%. Comparing base (58c41e8) to head (a936fc0).

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk   #21883   +/-   ##
=======================================
  Coverage   39.58%   39.58%           
=======================================
  Files        2130     2130           
  Lines       99558    99558           
  Branches    15350    15350           
=======================================
  Hits        39406    39406           
  Misses      56669    56669           
  Partials     3483     3483           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The existing `doFinish` argument is used to managed finishing the
activity after saving. Because we want to complete text composition for
this same context, reusing this argument seems appropriate.
@dcalhoun dcalhoun force-pushed the fix/mitigate-gutenberg-kit-text-composition-oddities branch from f47ec77 to a936fc0 Compare May 15, 2025 19:38
@dcalhoun dcalhoun marked this pull request as ready for review May 15, 2025 20:07
@dcalhoun dcalhoun requested a review from a team as a code owner May 15, 2025 20:07
@dcalhoun dcalhoun requested review from adalpari and removed request for a team May 15, 2025 20:08
Comment on lines +1970 to +1971
private fun updateAndSavePostAsyncOnEditorExit(listener: OnPostUpdatedFromUIListener?,
isFinishing: Boolean = false) {
Copy link
Contributor

@adalpari adalpari May 16, 2025

Choose a reason for hiding this comment

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

Suggested change
private fun updateAndSavePostAsyncOnEditorExit(listener: OnPostUpdatedFromUIListener?,
isFinishing: Boolean = false) {
private fun updateAndSavePostAsyncOnEditorExit(
listener: OnPostUpdatedFromUIListener?,
isFinishing: Boolean = false
) {

⛏️ Just following a more Kotlint style

@adalpari
Copy link
Contributor

  1. Use a Samsung device.

Unfortunately, I don't have any Samsung device to test this step

For Aztec: P9ugOq-4rN-p2
Not sure what this action means. I assume the Aztec editor is the native one?

@adalpari
Copy link
Contributor

adalpari commented May 16, 2025

I've tested all the scenarios except for the Samsung one, and they work as expected now. Thanks!

Screen.Recording.2025-05-16.at.09.44.23.mov

So, waiting for some clarification, especially what to do about Samsung, and I can then approve the PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gutenberg Editing and display of Gutenberg blocks. [Type] Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants