-
Notifications
You must be signed in to change notification settings - Fork 6k
[iOS] Ensure the keyboard bottom inset is zero when keyboard dismiss. #31982
Conversation
Just out of curiosity, why does keyboard with shorter height properly animates without this change? |
@coldstar96
I think maybe there are some issues in custom keyboard app. But making this change in engine side will make it more universal |
It's unfortunate that iOS keyboard notification is not called with consistency. I've been through so many weird behaviors with iOS framework that this is no surprise. Thanks for the explanation! |
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.
@coldstar96 were you able to confirm this fixes the issue since you can repro?
Very minor nits.
@gaaclarke can you give this a sanity check since you reviewed #29281 ?
@"UIKeyboardAnimationDurationUserInfoKey" : [NSNumber numberWithDouble:0.25], | ||
@"UIKeyboardIsLocalUserInfoKey" : [NSNumber numberWithBool:isLocal] |
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.
Use boxed literals
@"UIKeyboardAnimationDurationUserInfoKey" : [NSNumber numberWithDouble:0.25], | |
@"UIKeyboardIsLocalUserInfoKey" : [NSNumber numberWithBool:isLocal] | |
@"UIKeyboardAnimationDurationUserInfoKey" : @(0.25), | |
@"UIKeyboardIsLocalUserInfoKey" : @(isLocal) |
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.
done
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.
This looks good to me. @jmagman can you LGTM this?
@cyanglaz is reviewing. |
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.
Did some debugging, It looks like the root cause of the issue is the keyboardFrame
that we get from keyboardWillChangeFrame
is a not CGRectZero when the keyboard is going to hide. This might be a bug from iOS.
With the above behavior, I think this fix is a good workaround.
Note: I cannot reproduce the issue on iPhone. I can confirm the iPad issue is fixed with the PR.
Hi @cyanglaz ,What's your iPhone version ? My iPhone can reproduce it. |
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.
LGTM % nits
if (@available(iOS 9, *)) { | ||
// Ignore keyboard notifications related to other apps. | ||
id isLocal = info[UIKeyboardIsLocalUserInfoKey]; | ||
if (isLocal && ![isLocal boolValue]) { | ||
return; | ||
} | ||
} | ||
|
||
// Ignore keyboard notifications if engine’s viewController is not current viewController. | ||
if ([_engine.get() viewController] != self) { | ||
return; | ||
} |
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.
nits: This code is the same as in keyboardWillChangeFrame, maybe we can refactor it into a method.
cc @jmagman or @chinmaygarde for a second LGTM |
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.
This PR is to ensure the viewport metrics is correct when keyboard dismiss.
Related issue:
flutter/flutter#99951
flutter/flutter#100220
Demo code for first issue
Preview for flutter/flutter#99951
Before.MP4
After.mp4
Preview for flutter/flutter#100220
Before2.mp4
After2.mp4
Pre-launch Checklist
writing and running engine tests.
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.