paescebu / CustomKeyboardKit

Creating custom In App Keyboards with SwiftUI has never been easier!
GNU General Public License v3.0
201 stars 20 forks source link

Custom keyboard does not show when axis argument is provided (iOS 16+) #15

Closed fraune closed 9 months ago

fraune commented 9 months ago

Hello there! First off, thanks for your work on this package :)

I've been poking around with the library, and have found that when supplying the axis argument to a TextField, the custom keyboard no longer shows, falling back on the standard keyboard.

I created a repo which should clearly demonstrate the issue: https://github.com/fraune/CustomKeyboardKit_TextFieldAxis_BugDemo

I forked this repo to see if I could figure it out myself, but I don't have as much experience with introspect. I'd love to hear if you have some thoughts on how we can work through this issue.

Cheers, –Fraune

paescebu commented 9 months ago

Hey @fraune,

Thanks for the feedback, much appreciated, especially for the small example app, that accelerated my investigation! That now lead to some optimizations in the Interface of CustomKeyboardKit for simpler use of it for you and for other integrators! :-)

To quickly explain the root cause: It seems that as soon as you add the axis parameter SwiftUI creates a UITextArea under the hood instead of UITextField, causing the introspection to fail to find the right TextView. Additionally my implementation was limiting that if you use the customKeyboardmodifier on TextField that it expected a UITextField, and for a TextEditor it expected a UITextArea, where the reality (as your case showed) is different. CustomKeyboardKit should now be smarter more straight forward for it.

I just updated CustomKeyboardKit to 1.0.2. This should resolve your issue I think. let me know if it does! And I let you close the Issue if its resolved for you.

Thank you so much for your time and a great weekend Pascal

fraune commented 9 months ago

My guy. Quickest resolution ever! Thanks for the explanation as well.

Yep, confirming the update worked for my the demo project and my other project.

paescebu commented 9 months ago

Very glad to hear!

Have a great one. Ill close the ticket then.