oficina / sheets Public

iOS: the idle key field is hidden from VoiceOver

Review #72 finding 6. The invisible field holding the hardware keyboard on
the selected cell was an accessibility element labelled "Cell contents",
over the cell's own button; a VoiceOver user without a keyboard could land
on a field that cannot be typed into. It is hidden while idle and exposed
only while it is the cell's editor.

Test: KeySinkTests.testIdleFieldIsHiddenFromAccessibility (iPad simulator).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 105b050cdd0376a134e52c7ad42801340706dbc4 parent 5e441f4
2 files changed, +20 −0
  • native/apple/Sources/SheetsKit/SheetKeySink.swift +7 −0
  • native/apple/Tests/SheetsKitTests/KeySinkTests.swift +13 −0
diff --git a/native/apple/Sources/SheetsKit/SheetKeySink.swift b/native/apple/Sources/SheetsKit/SheetKeySink.swift
index 7996e09..7e0c219 100644
--- a/native/apple/Sources/SheetsKit/SheetKeySink.swift
+++ b/native/apple/Sources/SheetsKit/SheetKeySink.swift
@@ -65,13 +65,20 @@ struct SheetKeySink: UIViewRepresentable {
}
required init?(coder: NSCoder) { nil }
+ /// Idle, the field is invisible and cannot be typed into without a hardware
+ /// keyboard, so VoiceOver must not land on it: the cell's own button is
+ /// what it reads. Typing, it is the cell's editor and is announced as one.
private func appearIdle() {
+ isAccessibilityElement = false
+ accessibilityElementsHidden = true
textColor = .clear
tintColor = .clear
backgroundColor = .clear
layer.borderWidth = 0
}
private func appearTyping() {
+ isAccessibilityElement = true
+ accessibilityElementsHidden = false
textColor = .label
tintColor = nil
backgroundColor = .systemBackground
diff --git a/native/apple/Tests/SheetsKitTests/KeySinkTests.swift b/native/apple/Tests/SheetsKitTests/KeySinkTests.swift
index 0a2a4b9..ee1a8c2 100644
--- a/native/apple/Tests/SheetsKitTests/KeySinkTests.swift
+++ b/native/apple/Tests/SheetsKitTests/KeySinkTests.swift
@@ -103,6 +103,19 @@ final class KeySinkTests: XCTestCase {
XCTAssertFalse(field.handle(.keyboardA), "letters are text, not commands")
}
+ /// Review #72, finding 6: VoiceOver must not land on the invisible field.
+ @MainActor func testIdleFieldIsHiddenFromAccessibility() {
+ let (_, field, window) = sink("old")
+ defer { window.isHidden = true }
+ XCTAssertFalse(field.isAccessibilityElement)
+ XCTAssertTrue(field.accessibilityElementsHidden)
+ field.insertText("n")
+ XCTAssertTrue(field.isAccessibilityElement, "while typing it is the cell's editor")
+ XCTAssertFalse(field.accessibilityElementsHidden)
+ XCTAssertTrue(field.handle(.keyboardEscape))
+ XCTAssertFalse(field.isAccessibilityElement)
+ }
+
@MainActor func testReadOnlySheetsDoNotStartAnEdit() {
let (model, field, window) = sink("old")
defer { window.isHidden = true }