Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #942 from matrix-org/mauroromito/disable_autocorre…
Browse files Browse the repository at this point in the history
…ction

[iOS] Disabling auto correction
  • Loading branch information
stefanceriu authored Mar 8, 2024
2 parents e77f777 + 707730b commit 0b6fd00
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import XCTest

extension WysiwygUITests {
func testRichTextModeAutocorrection() throws {
func disable_testRichTextModeAutocorrection() throws {
textView.typeTextCharByChar("/")
XCTAssertFalse(image(.autocorrectionIndicator).exists)
textView.typeText(XCUIKeyboardKey.delete.rawValue)
Expand All @@ -29,7 +29,7 @@ extension WysiwygUITests {
XCTAssertTrue(image(.autocorrectionIndicator).exists)
}

func testPlainTextModeAutocorrection() throws {
func disable_testPlainTextModeAutocorrection() throws {
waitForButtonToExistAndTap(.plainRichButton)
textView.typeTextCharByChar("/")
XCTAssertFalse(image(.autocorrectionIndicator).exists)
Expand All @@ -42,12 +42,12 @@ extension WysiwygUITests {
XCTAssertTrue(image(.autocorrectionIndicator).exists)
}

func testRichTextModeNonLeadingCommand() throws {
func disable_testRichTextModeNonLeadingCommand() throws {
textView.typeTextCharByChar("text /not_a_command")
XCTAssertTrue(image(.autocorrectionIndicator).exists)
}

func testPlainTextModeNonLeadingCommand() throws {
func disable_testPlainTextModeNonLeadingCommand() throws {
waitForButtonToExistAndTap(.plainRichButton)
textView.typeTextCharByChar("text /not_a_command")
XCTAssertTrue(image(.autocorrectionIndicator).exists)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ struct UITextViewWrapper: UIViewRepresentable {
functionName: #function
)
didUpdateText()
textView.toggleAutocorrectionIfNeeded()
// Disabled always until we fix the predictive text issue
// textView.toggleAutocorrectionIfNeeded()
textView.invalidateIntrinsicContentSize()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ public class WysiwygComposerViewModel: WysiwygComposerViewModelProtocol, Observa
/// The textView that the model currently manages, a default text view is provided, but you should always inject it from the UIWrapper
public lazy var textView = {
let textView = WysiwygTextView()
// Disabled until we fix the issue with the predictive text
textView.autocorrectionType = .no
textView.linkTextAttributes[.foregroundColor] = parserStyle.linkColor
textView.mentionDisplayHelper = mentionDisplayHelper
textView.apply(attributedContent)
return textView
}() {
didSet {
// Disabled until we fix the issue with the predictive text
textView.autocorrectionType = .no
textView.linkTextAttributes[.foregroundColor] = parserStyle.linkColor
textView.mentionDisplayHelper = mentionDisplayHelper
textView.apply(attributedContent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public class WysiwygTextView: UITextView {
flusher.flush()
}
didSet {
toggleAutocorrectionIfNeeded()
// Disabled until we fix the predictive text issue
// toggleAutocorrectionIfNeeded()
delegate?.textViewDidChange?(self)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
@testable import WysiwygComposer
import XCTest

// THESE TESTS ARE DISABLED UNTIL WE FIX THE PREDICTIVE TEXT ISSUE
extension WysiwygComposerViewModelTests {
func testAutocorrectionIsDisabled() throws {
func disabled_testAutocorrectionIsDisabled() throws {
mockTrailingTyping("/")
assertAutocorrectDisabled()

Expand All @@ -29,20 +30,20 @@ extension WysiwygComposerViewModelTests {
assertAutocorrectDisabled()
}

func testAutocorrectionIsEnabled() throws {
func disabled_testAutocorrectionIsEnabled() throws {
mockTrailingTyping("Just some text")
assertAutoCorrectEnabled()

mockTrailingTyping(" /not_a_command")
assertAutoCorrectEnabled()
}

func testDoubleSlashKeepAutocorrectionEnabled() throws {
func disabled_testDoubleSlashKeepAutocorrectionEnabled() throws {
mockTrailingTyping("//")
assertAutoCorrectEnabled()
}

func testAutocorrectionIsReEnabled() throws {
func disabled_testAutocorrectionIsReEnabled() throws {
mockTrailingTyping("/")
assertAutocorrectDisabled()

Expand All @@ -58,7 +59,7 @@ extension WysiwygComposerViewModelTests {
assertAutoCorrectEnabled()
}

func testAutocorrectionAfterSetHtmlContent() {
func disabled_testAutocorrectionAfterSetHtmlContent() {
viewModel.setHtmlContent("/join #some_room:matrix.org")
assertAutocorrectDisabled()

Expand All @@ -79,7 +80,7 @@ extension WysiwygComposerViewModelTests {
// assertAutoCorrectEnabled()
// }

func testAutocorrectionAfterSetMarkdownContent() {
func disabled_testAutocorrectionAfterSetMarkdownContent() {
viewModel.setMarkdownContent("/join #some_room:matrix.org")
assertAutocorrectDisabled()

Expand Down

0 comments on commit 0b6fd00

Please sign in to comment.