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

Soft keyboard won't hide in CardView even with explicit unfocus call #1

Open
minkyn opened this issue Jan 12, 2025 · 3 comments
Open

Comments

@minkyn
Copy link

minkyn commented Jan 12, 2025

In the example, for the widget that contains the CardView and a button, if you click the button without dismissing the soft keyboard on a mobile device, the keyboard would stay on.

I tried adding a FocusManager.instance.primaryFocus?.unfocus() as the first thing as well as after tokenize call for the button's onPressed callback, but it doesn't work and I can still see the cursing blinking in the CardView without giving up the focus.

The original Square web SDK doesn't have this issue though.

@rpelavin
Copy link
Member

@minkyn thank you for taking the time to report! I should have time to take a look within the next week. Will happily review any pull request as well :)

@minkyn
Copy link
Author

minkyn commented Jan 13, 2025

I have been investigating but haven't yet figured it out. This doesn't happen in my Android phones, only in iPhone with either Chrome or Safari. Basically the symptom is that I can find no way to unfocus from the Square CardView.

So far I have tried FocusManager.instance.primaryFocus?.unfocus(), FocusScope.of(context).unfocus(), FocusScope.of(context).requestFocus(FocusNode()) and SystemChannels.textInput.invokeMethod('TextInput.hide') when clicking a button, and none of them worked. I did add a new random TextField, and manually clicking into it could unfocus from CardView, and then calling one of the previous four methods was able to unfocus from that TextField as expected.

In summary, it looks like the traditional programmatic way of unfocusing doesn't work for the CardView only.

I'm not sure if this is a bug of this plugin or flutter, as I know CardView is essentially wrapping on top of HtmlElementView. I do notice that there is such a comment here. Maybe this doesn't work as what the comment claims to be?

@rpelavin
Copy link
Member

Thanks @minkyn, I'm able to reproduce the behavior you describe. I believe focus/unfocus synchronization needs to be added between the Flutter CardView and the underlying HTML input element. I'll take a stab at addressing by EOW.

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

No branches or pull requests

2 participants