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

Fix and improve autocomplete popup size #2919

Closed
wants to merge 2 commits into from

Conversation

borisyankov
Copy link
Contributor

@borisyankov borisyankov commented Aug 26, 2018

Fixes #2917

Makes the sizing of the autocomplete popup more consistent and logical.

Fixes zulip#2917

Several previous changes regressed the styling of the Popup.

The ideal size of the popup can be described as:
'the whole screen sans the keyboard and with some padding around'.

The lack of CSS `position` prop value of `fixed` being supported,
and the lack of React portals (another option) support makes implementing
this tricky and requires a lot of rework.

This commit finds a good middle ground - use a max height of half the
screen height minus the compose box's height.
Make the layout styling of Popup component more consistently:
* layout using material design padding/margin values
* 'bottom' styling is not needed
* 'shadowOpacity' and 'shadowRadius' to distinguish the popup
better from the background
Copy link
Member

@jainkuniya jainkuniya left a comment

Choose a reason for hiding this comment

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

return (
<View style={[styles.wrapper, { marginBottom }]}>
<View style={[styles.wrapper, { height: height / 2 - marginBottom, marginBottom }]}>
Copy link
Member

Choose a reason for hiding this comment

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

(Before we had it as 1/4 of height, to tackle landscape scenario too b4cd7c8)

@gnprice
Copy link
Member

gnprice commented Sep 24, 2018

For me this results in some bad mis-layout as soon as I focus the compose box:
screenshot_1537823801
The app bar is gone; plus the input is partially obscured by the keyboard.

That's on an emulated Pixel 2 XL, on Android 8.

Perhaps the issue is that the render method with the Dimensions.get call isn't getting re-run when the keyboard pops up, and so we're still basing the size on the old dimensions?

More broadly, even if we find a way to do this that seems to work, I'd worry about edge cases where we don't get re-rendered -- even if we find a way that it's clearly documented should work, this feels like an area where RN is likely to have bugs in edge cases, because at least on Android it's a notoriously tricky area to get right. (What if the user enters split-screen mode? Or leaves it? Or moves their focus between split screens? Or if the keyboard itself aborts, or changes its height?)

So I'd be more confident if we can find a solution that doesn't involve our code having to find out the height.

@gnprice
Copy link
Member

gnprice commented Sep 24, 2018

Ah, playing with the react-devtools inspector a bit, I think I see the reason this is tricky: it's that we have AutocompleteViewWrapper as a child of ComposeBox, when the layout we're going for really calls for making it a sibling of ComposeBox and of MessageList.

Pulling it up to be a sibling will require some tricky rewiring of how the autocomplete communicates with the input fields, as it'll be one layer farther away. I think that's totally doable, but it'll be less work if we wait to do it until we've de-duplicated ComposeBox again -- which we had a previous effort at in #2886, but now is probably best done after upgrading to RN v0.57, which in turn will follow #2788 / #2789 upgrading to v0.56.

Meanwhile, we should do something to make the autocomplete at least not look broken. How about setting its height to a fixed number of rows -- like 5? That should be an improvement over the status quo.

@gnprice gnprice changed the title Fix and improve autocomplete Fix and improve autocomplete popup size Sep 26, 2018
@gnprice
Copy link
Member

gnprice commented Oct 1, 2018

@borisyankov and I chatted a bit about this today.

  • The second commit is a simple styling fixup that's independent of the major layout change. I'm going to go ahead and merge it.
  • The other commit, we'll skip. As discussed above, we'll come back and fix this the right way after we lay some groundwork; in the meantime we'll do a quick fix like a fixed height.

@gnprice
Copy link
Member

gnprice commented Oct 1, 2018

As always for a UI change, some screenshots make a key piece of the PR. For this one, I took some just now.

These are for just the smaller (second) commit on its own.

Before:
image

After:
image

@gnprice
Copy link
Member

gnprice commented Oct 1, 2018

Merged that piece as 69ece87. Thanks @borisyankov !

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

Successfully merging this pull request may close these issues.

3 participants