Repository navigation
Android MobBridge.dismissKeyboard() for Mob.Keyboard.dismiss/1 - #113
Merged
Merged
Conversation
….dismiss/1 Hides the soft keyboard (InputMethodManager.hideSoftInputFromWindow) and clears focus on the UI thread, so the field's on_blur fires as on iOS, where dismissing resigns the first responder. mob's dismiss_keyboard NIF looks it up with cacheOptional by name and ()V (GenericJam/mob#173). Verified on a Moto G Power 2021: the decimal keyboard goes down (dumpsys input_method mInputShown=false), a value assigned in the same handler reaches the field, on_blur arrives, and the next tap focuses the field again.
A field in a Mob.UI.sheet renders in ModalBottomSheet's separate window, so activity.currentFocus carried the wrong window token: the IME ignored the hide and the field kept focus (verified on a Moto G Power 2021). MobTextField now records its LocalView on focus and dismissKeyboard targets it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
MobBridge.dismissKeyboard()in the generated Android bridge: the Android half ofMob.Keyboard.dismiss/1(GenericJam/mob#173, by @tmepple, who proposed this change).InputMethodManager.hideSoftInputFromWindowon the focused view, falling back to the decor view) and callsclearFocus()on the focused view.@JvmStatic fun dismissKeyboard(), matching the()Vdescriptor mob's NIF looks up withcacheOptional. Placed next tohaptic, and fire-and-forget like it.on_blurnever fired and the next tap on the field sent noon_focus.project_generator_test.exschecks that the generated bridge declares the static method with the right shape, the import, and both calls.[Unreleased]: Added, plus an Upgrading note for existing apps (copy the method and import).Depends on
GenericJam/mob#173 for the NIF. Without that mob change the method is just never called. The other way round, an app on mob#173 with an older bridge gets
{:error, :not_loaded}, whichdismiss/1swallows.Verified
Moto G Power 2021 (Android 11), with a throwaway app generated from this branch (
--local, mob at #173). Its screen has akeyboard: :decimalfield and buttons whose handlers callMob.Keyboard.dismiss/1:mInputShown=true. After "dismiss + assign value 42.5",mInputShown=falseand the field shows42.5; the screenshots agree.on_blurarrived. This needs mob#173's identity-tolerant Android blur: before that change, 2 of 8 arrived. All 10on_focusarrived on re-tap, and tapping the field again brings the keyboard back.dismissKeyboard not found (optional), the raw NIF returns{:error, :not_loaded}, the keyboard stays up, the assigned value still reaches the field, and the app keeps running.mix test(535 passed, withMOB_DIRset to the mob#173 worktree andMOB_DEV_DIRset to mob_dev master),mix format --check-formatted,mix credo --strict.