-
-
Notifications
You must be signed in to change notification settings - Fork 50
#188: Add support to swiping to dismiss keyboard for UIKitBackend #193
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
Conversation
Thanks for the PR! This will be a nice quality of life improvement. I believe that multiline text editing on iOS usually supports the interactive dismissal style. For example the notes app lets you scroll with the keyboard open, but if your finger enters the keyboard while scrolling it begins scrolling away the keyboard. I feel like that should be the default for SwiftCrossUI as well. In addition to setting the keyboardDismissMode property on text editors in UIKitBackend, I believe you'll have to set it on scroll views(because the way SwiftCrossUI uses text editors means that they never end up being scrollable; it always makes them big enough to fit their content). |
@stackotter Got it, that makes sense. I’ll take a look at it tomorrow. |
I also meant to mention that this codebase uses indented switch case blocks, so please update that in your PR while you're at it as well. switch foo {
case .bar:
...
case .baz:
...
} |
@stackotter I’ve made the changes. Can you check if it works the way you had in mind? I also included examples in the description using it with TextEditor and ScrollView. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making those changes 🙏 I just looked through the code and you've done it all basically exactly how I would've done it. It all works well on my phone as well. I've just left a few comments for smaller formatting/documentation things and suggested adding an automatic
mode for future proofing.
…ly minor adjustments
@stackotter all set, I’ve included all the changes in the last commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing those comments, looks good now
Will merge once the CI finishes |
@stackotter Just bringing this PR back to your radar |
Ah yep thanks! Forgot that I hadn't merged hahah |
Summary
This PR adds support for the
.scrollDismissesKeyboard(_:)
modifier toTextEditor
on iOS, allowing developers to control how the keyboard is dismissed during scroll interactions.By default,
TextEditor
now uses.never
, meaning it will not dismiss the keyboard when the user scrolls. This aligns with typical multi-line text editing behavior on iOS, and differs from other scrollable views, which may dismiss the keyboard unless configured otherwise.This change addresses stackotter/swift-cross-ui#188.
UIKitBackend
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-06-23.at.21.58.28.mov
Simulator.Screen.Recording.-.iPhone.16.Pro.-.2025-06-24.at.13.27.57.mov