From b352381210299e5fa11bbe496f9ce25d801ffb80 Mon Sep 17 00:00:00 2001 From: Mathias Claassen Date: Mon, 17 Jan 2022 16:30:23 -0300 Subject: [PATCH 1/3] Fix crash when user taps tab key on external keyboard --- Source/Core/Core.swift | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Source/Core/Core.swift b/Source/Core/Core.swift index 1c7ffddfc..26908fc46 100644 --- a/Source/Core/Core.swift +++ b/Source/Core/Core.swift @@ -1088,6 +1088,27 @@ extension FormViewController { navigateTo(direction: .down) } + open override func pressesBegan(_ presses: Set, with event: UIPressesEvent?) { + var didHandleEvent = false + for press in presses { + guard let key = press.key else { continue } + if key.keyCode == .keyboardTab, + !key.modifierFlags.contains(.command) { + if key.modifierFlags.contains(.shift) { + navigateTo(direction: .up) + } else { + navigateTo(direction: .down) + } + didHandleEvent = true + } + } + + if !didHandleEvent { + // Didn't handle this key press, so pass the event to the next responder. + super.pressesBegan(presses, with: event) + } + } + public func navigateTo(direction: Direction) { guard let currentCell = tableView?.findFirstResponder()?.formCell() else { return } guard let currentIndexPath = tableView?.indexPath(for: currentCell) else { return } From cd05184e09d380bb333aef9a4958e52b5f83d8e5 Mon Sep 17 00:00:00 2001 From: Mathias Claassen Date: Mon, 17 Jan 2022 18:30:32 -0300 Subject: [PATCH 2/3] Fix CI Xcode version --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6a17e22b..6cb92e3ea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,9 +11,12 @@ jobs: runs-on: macOS-latest strategy: matrix: - destination: ['platform=iOS Simulator,OS=14.4,name=iPhone 11'] + destination: ['platform=iOS Simulator,OS=15.2,name=iPhone 11'] steps: - uses: actions/checkout@v2 + - uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '13.2.1' - name: Build and test run: set -o pipefail && xcodebuild -project Eureka.xcodeproj -scheme 'Eureka' -sdk 'iphonesimulator' -destination "${{ matrix.destination }}" -configuration Debug test | xcpretty From 272d06e53e1d9b1e0c6c433252042c87ff8a86b2 Mon Sep 17 00:00:00 2001 From: Mathias Claassen Date: Tue, 18 Jan 2022 12:01:38 -0300 Subject: [PATCH 3/3] Address comments and fix warning --- Source/Core/Cell.swift | 2 +- Source/Core/Core.swift | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Source/Core/Cell.swift b/Source/Core/Cell.swift index 7d0082384..84d138f45 100644 --- a/Source/Core/Cell.swift +++ b/Source/Core/Cell.swift @@ -52,7 +52,7 @@ open class BaseCell: UITableViewCell, BaseCellType { if let formVC = responder as? FormViewController { return formVC } - responder = (responder as? UIResponder)?.next + responder = responder?.next } return nil } diff --git a/Source/Core/Core.swift b/Source/Core/Core.swift index 26908fc46..1faa07d9d 100644 --- a/Source/Core/Core.swift +++ b/Source/Core/Core.swift @@ -1091,16 +1091,15 @@ extension FormViewController { open override func pressesBegan(_ presses: Set, with event: UIPressesEvent?) { var didHandleEvent = false for press in presses { - guard let key = press.key else { continue } - if key.keyCode == .keyboardTab, - !key.modifierFlags.contains(.command) { - if key.modifierFlags.contains(.shift) { - navigateTo(direction: .up) - } else { - navigateTo(direction: .down) - } - didHandleEvent = true + guard let key = press.key, + key.keyCode == .keyboardTab, + !key.modifierFlags.contains(.command) else { continue } + if key.modifierFlags.contains(.shift) { + navigateTo(direction: .up) + } else { + navigateTo(direction: .down) } + didHandleEvent = true } if !didHandleEvent {