Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when user taps tab key on external keyboard #2205

Merged
merged 3 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Choose a reason for hiding this comment

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

I assume this updates your framework to be built against iOS 15.2 and Xcode version 13.2.1?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but just for the tests


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
2 changes: 1 addition & 1 deletion Source/Core/Cell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
20 changes: 20 additions & 0 deletions Source/Core/Core.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1088,6 +1088,26 @@ extension FormViewController {
navigateTo(direction: .down)
}

open override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
var didHandleEvent = false
for press in presses {
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 {
// 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 }
Expand Down