Commit a9a6a63
authored
fix(web): prevent Focus exception after feedback submission and window restore (#359)
* Fix Focus exception in web
This hotfix addresses a Focus exception that occurs on the Web platform when a user submits feedback and then hides/restores the browser window. The issue stems from a focus context being accessed before it's properly attached.
* fix(keyboard): improve keyboard hiding logic with focus check
Refactored _hideKeyboard method to use FocusScope.of(context).unfocus() only when there's an active focus that is not the primary focus. This is more precise than calling requestFocus(FocusNode()), which can cause issues like:
Attaching a focus node without context may throw runtime exceptions.
It introduces unnecessary focus traversal, which may lead to unexpected behavior in complex focus trees.
unfocus() is a cleaner, Flutter-recommended way to dismiss the keyboard.
This approach safely checks focus state and dismisses the keyboard only when appropriate, avoiding crashes and unwanted side effects.1 parent 894e7d1 commit a9a6a63
1 file changed
+5
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
356 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
357 | 361 | | |
358 | 362 | | |
359 | 363 | | |
| |||
0 commit comments