Skip to content

ChatScreen: Fix blank strip between compose box and keyboard on iOS#5564

Merged
chrisbobbe merged 1 commit intozulip:mainfrom
chrisbobbe:pr-fix-ios-blank-strip
Nov 23, 2022
Merged

ChatScreen: Fix blank strip between compose box and keyboard on iOS#5564
chrisbobbe merged 1 commit intozulip:mainfrom
chrisbobbe:pr-fix-ios-blank-strip

Conversation

@chrisbobbe
Copy link
Copy Markdown
Contributor

Before/after:

Fixes: #3370

@chrisbobbe chrisbobbe added a-iOS a-layout a-compose/send Compose box, autocomplete, camera/upload, outbox, sending labels Nov 18, 2022
@chrisbobbe chrisbobbe requested review from alya and gnprice November 18, 2022 20:32
Comment thread src/chat/ChatScreen.js Outdated
Comment on lines +203 to +207
keyboardVerticalOffset={
// This is a slight misuse of this prop: this value is not (to quote
// from the jsdoc) "How much the top of `KeyboardAvoider`'s layout
// *parent* is displaced downward from the top of the screen." That
// value would be zero.
//
// This addresses an issue where the strip that covers the bottom
// inset would scoot up above the keyboard with the rest of the
// compose box when the keyboard opens, leaving a blank strip of
// wasted space ( #3370). We haven't yet found a better way to avoid
// this, while still letting `ComposeBox` control how it occupies
// the inset (like how our header components occupy the top inset).
-useSafeAreaInsets().bottom
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm fascinating.

What does this look like when the keyboard isn't open? Does it cause the compose box to be lowered into the inset area, where it's obscured at the bottom? On its face it seems like it would.

It looks like this would become our one use of this keyboardVerticalOffset prop. If something like this is right, then perhaps the jsdoc on it isn't right and should be edited? It looks like we added that prop in 70eca07 / #4683 and have never yet used it in main. (It subsequently appeared in #4893, in a previous revision of this same commit.)

@chrisbobbe chrisbobbe force-pushed the pr-fix-ios-blank-strip branch from 583a5ca to 281bcdc Compare November 19, 2022 01:26
@chrisbobbe
Copy link
Copy Markdown
Contributor Author

Thanks for the review, and for finding a better solution just now in discussion in the office! 🙂 Revision pushed.

Copy link
Copy Markdown
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good -- small comment-comments below.

Comment on lines +39 to +45
* Use this when a child component uses SafeAreaView to pad the bottom
* inset, and you want the open keyboard to cover that padding.
*
* (SafeAreaView has a bug where it applies a constant padding no matter
* where it's positioned onscreen -- so in particular, if you ask for
* bottom padding, you'll get bottom padding even when KeyboardAvoider
* pushes the SafeAreaView up and out of the bottom inset.)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems very clear, thanks!

Comment thread src/chat/ChatScreen.js
Comment on lines +203 to +206
compensateOverpadding={
// We let the compose box pad the bottom inset.
showComposeBox
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have a comment at the use of SafeAreaView in ComposeBox, too, saying that when the keyboard is open it's compensated for here.

Comment thread src/common/KeyboardAvoider.js Outdated
Comment on lines +78 to +79
keyboardVerticalOffset={
keyboardVerticalOffset + (compensateOverpadding ? -bottomInsetHeight : 0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this spot we're abusing the keyboardVerticalOffset prop of KeyboardAvoider -- what we're doing doesn't match its intended interface. So a comment to acknowledge that would be helpful, letting the reader know the mismatch is intentional and they're not just missing something. Like this, say:

Suggested change
keyboardVerticalOffset={
keyboardVerticalOffset + (compensateOverpadding ? -bottomInsetHeight : 0)
keyboardVerticalOffset={
keyboardVerticalOffset
// A negative term here reduces the bottom inset we use for the child,
// when the keyboard is open, so that the keyboard covers its bottom padding.
+ (compensateOverpadding ? -bottomInsetHeight : 0)

@chrisbobbe chrisbobbe force-pushed the pr-fix-ios-blank-strip branch from 281bcdc to 9ed6fd3 Compare November 21, 2022 22:18
@chrisbobbe
Copy link
Copy Markdown
Contributor Author

Thanks for the review! Revision pushed.

@alya
Copy link
Copy Markdown
Collaborator

alya commented Nov 22, 2022

Cool, the screenshot looks good to me!

@gnprice
Copy link
Copy Markdown
Member

gnprice commented Nov 23, 2022

Thanks for the revision!

This all looks good except it introduces a lint warning in ChatScreen -- see #5569 for why tools/test isn't currently catching that. Easiest way to check for it, pending #5569, is to open the file in the IDE.

Please merge at will after fixing that.

@chrisbobbe chrisbobbe force-pushed the pr-fix-ios-blank-strip branch from 9ed6fd3 to ee6630e Compare November 23, 2022 01:28
@chrisbobbe
Copy link
Copy Markdown
Contributor Author

chrisbobbe commented Nov 23, 2022

Merging with that fix, thanks for the review!

@chrisbobbe chrisbobbe force-pushed the pr-fix-ios-blank-strip branch from ee6630e to cbdc035 Compare November 23, 2022 01:30
@chrisbobbe chrisbobbe merged commit cbdc035 into zulip:main Nov 23, 2022
@chrisbobbe chrisbobbe deleted the pr-fix-ios-blank-strip branch November 23, 2022 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a-compose/send Compose box, autocomplete, camera/upload, outbox, sending a-iOS a-layout

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blank strip between compose box and keyboard

3 participants