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 e435ca3 commit 79b7973
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

0 comments on commit 79b7973

Please sign in to comment.