cashapp / AccessibilitySnapshot

Easy regression testing for iOS accessibility

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SwiftUI `TextEditor` bounding box does not render properly

DavidBrunow opened this issue · comments

Given this snapshot test:

    @available(iOS 14.0, *)
    func testTextEditor() {
        let textEditor = TextEditor(text: .constant(""))
            .frame(
                width: UIScreen.main.bounds.width,
                height: UIScreen.main.bounds.height
            )
            .border(Color.black)

        assertSnapshot(
            matching: textEditor,
            as: .accessibilityImage,
            named: nameForDevice()
        )
    }

The library renders this snapshot where the accessibility bounding box does not match the text editor's frame (note that the missing description for the Text Field is being worked in #186):
testTextEditor 393x852-16-4-3x

This misrendering does not occur if the text editor is wrapped in a UIHostingController before calling assertSnapshot.