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

Keyboard Avoidance Issue #89

Closed
stevengharris opened this issue Feb 4, 2023 · 0 comments · Fixed by #130
Closed

Keyboard Avoidance Issue #89

stevengharris opened this issue Feb 4, 2023 · 0 comments · Fixed by #130

Comments

@stevengharris
Copy link
Owner

stevengharris commented Feb 4, 2023

As noted in #87, the MarkupEditorView does not avoid the keyboard when in a ScrollView. Raising this issue here just so it's clearer.

Here is an example that shows the different behavior between a MarkupEditorView and a TextField.

struct ContentView: View, MarkupDelegate {
        
    @State private var text = "Hello World"
    @State private var loaded: Bool = false
    @State private var demoHtml: String = "<h1>Hello World</h1>"
    
    
    var body: some View {
        ScrollViewReader { proxy in
            ScrollView {
                Rectangle()
                    .frame(height: 1000)
                MarkupEditorView(markupDelegate: self, html: $demoHtml).id(1)
                    .frame(height: 200)
                    .overlay(
                        RoundedRectangle(cornerRadius: 6.0)
                            .stroke(.gray, lineWidth: 1.0)
                    )
                    .onChange(of: loaded) { _ in
                        withAnimation {
                            proxy.scrollTo(1)
                        }
                    }
                TextField("Name:", text: $text)
            }
            .padding()
        }
    }
    
    func markup(_ view: MarkupWKWebView, heightDidChange height: Int) {
        loaded = true
    }
    
}

If you select in the TextField, the ScrollView scrolls upward to expose the insertion point. With MarkupEditorView, the insertion point will be covered by the keyboard. They MarkupEditorView needs to have the same behavior as TextField.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant