Skip to content

Commit

Permalink
Allow @ char in posts in mobile editor
Browse files Browse the repository at this point in the history
This fixes a bug with the @-mention feature that made entering the standalone @ character difficult because of the @-mention UI getting in the way.
The fix here is to allow the @ character to be intercepted without being consumed by the @ key event logic.
  • Loading branch information
guarani committed Aug 6, 2020
1 parent af53147 commit 7237a57
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/react-native-aztec/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/master/packages#maintaining-changelogs. -->

## Unreleased
## Unreleased

* Fixed a bug in the @-mentions feature where dismissing the @-mentions UI removed the @ character from the post.
11 changes: 6 additions & 5 deletions packages/react-native-aztec/ios/RNTAztecView/RCTAztecView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,12 @@ class RCTAztecView: Aztec.TextView {
// MARK: - Edits

open override func insertText(_ text: String) {
guard !interceptEnter(text), !interceptTriggersKeyCodes(text) else {
guard !interceptEnter(text) else {
return
}

interceptTriggersKeyCodes(text)

super.insertText(text)
updatePlaceholderVisibility()
}
Expand Down Expand Up @@ -374,13 +376,13 @@ class RCTAztecView: Aztec.TextView {
return true
}

private func interceptTriggersKeyCodes(_ text: String) -> Bool {
private func interceptTriggersKeyCodes(_ text: String) {
guard let keyCodes = triggerKeyCodes,
keyCodes.count > 0,
let onKeyDown = onKeyDown,
text.count == 1
else {
return false
return
}
for value in keyCodes {
guard let keyString = value as? String,
Expand All @@ -393,9 +395,8 @@ class RCTAztecView: Aztec.TextView {
var eventData = [AnyHashable:Any]()
eventData = add(keyCode: keyCode, to: eventData)
onKeyDown(eventData)
return true
return
}
return false;
}

private func isNewLineBeforeSelectionAndNotEndOfContent() -> Bool {
Expand Down

0 comments on commit 7237a57

Please sign in to comment.