Skip to content

Commit

Permalink
[RNMobile] Prevent blocks being un-wantingly replaced with newly adde…
Browse files Browse the repository at this point in the history
…d blocks (#49154)

The changes in logic surrounding dictation handling in #49056 led to a regression where currently selected blocks are replaced with newly added blocks. This PR addresses that issue by reverting the changes to the dictation logic.
  • Loading branch information
Siobhan Bamber committed Mar 17, 2023
1 parent b7c693b commit 584c1d2
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions packages/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,7 @@ class RCTAztecView: Aztec.TextView {
/// the dictation engine refreshes the TextView with an empty string when the dictation finishes.
/// This helps to avoid propagating that unwanted empty string to RN. (Solving #606)
/// on `textViewDidChange` and `textViewDidChangeSelection`
private var isInsertingDictationResult: Bool = {
if #available(iOS 16, *) {
return true;
} else {
return false;
}
}()
private var isInsertingDictationResult = false

// MARK: - Font

Expand Down Expand Up @@ -364,14 +358,10 @@ class RCTAztecView: Aztec.TextView {
}

public override func insertDictationResult(_ dictationResult: [UIDictationPhrase]) {
let objectPlaceholder = "\u{FFFC}"
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)
}
isInsertingDictationResult = false
self.text = self.text?.replacingOccurrences(of: objectPlaceholder, with: dictationText)
}

// MARK: - Custom Edit Intercepts
Expand Down

1 comment on commit 584c1d2

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 584c1d2.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4446826432
📝 Reported issues:

Please sign in to comment.