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

[RNMobile] Newly block replaces currently selected block on iOS #49145

Closed
SiobhyB opened this issue Mar 16, 2023 · 2 comments · Fixed by #49154
Closed

[RNMobile] Newly block replaces currently selected block on iOS #49145

SiobhyB opened this issue Mar 16, 2023 · 2 comments · Fixed by #49154
Labels
Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) [Priority] High Used to indicate top priority items that need quick attention [Type] Regression Related to a regression in the latest release

Comments

@SiobhyB
Copy link
Contributor

SiobhyB commented Mar 16, 2023

Description

A recent regression on iOS-only causes a selected block to be completely replaced when a new block is added via the inserter.

Step-by-step reproduction instructions

The installable build at wordpress-mobile/WordPress-iOS#20340 can be used to test the issue on a physical device:

  1. Navigate through the steps to create a new post in the iOS app.
  2. Type some text into a paragraph block.
  3. Tap the inserter in the editor's toolbar.
  4. Select a new block to add to the editor.

Expected behaviour

The new block should be added below the currently selected paragraph block.

Actual behaviour

The new block replaces the currently selected paragraph block, causing its content to be lost.

Screenshots or screen recording (optional)

In the following screen recording you can see the paragraph block being replaced by an image block:

bug.mov
@SiobhyB SiobhyB added [Priority] High Used to indicate top priority items that need quick attention [Type] Regression Related to a regression in the latest release Mobile App - i.e. Android or iOS Native mobile impl of the block editor. (Note: used in scripts, ping mobile folks to change) labels Mar 16, 2023
@derekblank
Copy link
Member

In testing, I noted that this issue occurs only on text-based blocks where the input is still focused.
For example, if the user is typing in a paragraph block and inserts another block with the text input focused (i.e., not tapping out of the block), the paragraph block will disappear and be replaced by the new block (and the text content is lost). However, if the user types text in any block with a text input (paragraph, caption, quote) and then taps out of the block to blur the input, the content is not lost, and the new block is inserted as normal. Here's an example of that interaction:

Untitled.mov

@derekblank
Copy link
Member

derekblank commented Mar 17, 2023

I believe the cause of this is something in insertDictationResult is prompting Aztec to believe there is no text input until the user "finishes" dictating, i.e., taps out to blur the input. This is partially known and has already been discussed on this thread.

public override func insertDictationResult(_ dictationResult: [UIDictationPhrase]) {
let dictationText = dictationResult.reduce("") { $0 + $1.text }
if #available(iOS 16, *) {
insertText(dictationText)
} else {
let objectPlaceholder = "\u{FFFC}"
isInsertingDictationResult = false
self.text = self.text?.replacingOccurrences(of: objectPlaceholder, with: dictationText)
}
}

My hypothesis is that insertDictationResult is somehow governing how RCTAztecView handles all text input from something in the #49056 change, and not just when the user is not using dictation.

I tried to come up with a fix where we could keep the iOS 16 dictation fix from #49056 but also fix the general text input block insertion issue, which seems like a bigger regression than the original dictation one. Possible ideas would be to keep all of the recent iOS 16 dictation fix code, but isolate it from Aztec for when the user is not using dictation. @SiobhyB has also outlined possible ideas in this comment: wordpress-mobile/gutenberg-mobile#5165 (comment)

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) [Priority] High Used to indicate top priority items that need quick attention [Type] Regression Related to a regression in the latest release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants