-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Fix MentionSuggestions gap in android #58488
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 MentionSuggestions gap in android #58488
Conversation
…to fix/android-suggestions-gap
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid-app-2025-04-01_16.12.54.mp4Android: mWeb Chromeandroid-chrome-2025-04-01_16.17.41.mp4iOS: Nativeios-app-2025-04-01_16.35.02.mp4iOS: mWeb Safariios-safari-2025-04-01_16.37.53.mp4MacOS: Chrome / Safaridesktop-chrome-2025-04-01_16.10.36.mp4MacOS: Desktopdesktop-app-2025-04-01_16.20.04.mp4 |
|
@zirgulis Thanks! Would you be able to add screenshots for other platforms, just for completeness? |
Usually, yes! I understand it's a bit annoying to do when you know for sure that the changes only affect one platform, but my understanding is we always enforce it to ensure there isn't some edge case where other platforms are unexpectedly affected. |
This comment was marked as resolved.
This comment was marked as resolved.
|
@jjcoffee I found some issues with the current approach, working on a fix, will ping you here in a few hours |
|
@jjcoffee could you please have another look? I've added some fixes |
|
Thanks, I'll retest tomorrow! |
This comment was marked as resolved.
This comment was marked as resolved.
|
@jjcoffee hmmm this is what I see on my end: Could you please try running:
This should make sure that there's no cached files and it should pickup the latest code changes |
This comment was marked as resolved.
This comment was marked as resolved.
|
@jjcoffee I added a commit with some console.logs for debugging. Could you please share what you get printed out? |
|
@zirgulis Here ya go: windowHeight 890.2857142857143 - (cursorCoordinates.y 27.809524536132812 - scrollValue 0 + y 793.5238647460938) - keyboardHeight -24 = 92.95232500348777
getBottomSuggestionPadding height 890.285714
AutoCompleteSuggestionsPortal bottomPadding 30
AutoCompleteSuggestionsPortal bottom + bottomPadding 122.952325 |
|
@jjcoffee thank you so much for the details! I've made some fixes, could you please check again if it works on your end? |
|
Thanks, I'll retest tomorrow! |
|
@zirgulis Nice, that's much better! One slight issue still, once the android-app-2025-03-26_15.58.47.mp4 |
@jjcoffee yes that bug is also present on iOS: This happens because I think we can live with this since this seems like a corner case. In order to fix this we would need to do an extensive refactoring of all the code related to AutoCompleteSuggestions. |
|
@zirgulis Okay thanks for confirming, that's fine if it's an existing bug. |
| function getBottomSuggestionPadding(bottom: number): number { | ||
| const {height} = Dimensions.get('window'); | ||
|
|
||
| const bottomPercentageToHeight = (bottom / height) * 100; |
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.
@zirgulis Could you add some explanatory comments here? There's a lot of magic numbers that future devs won't know what to do with 😄
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.
@jjcoffee done!
|
@zirgulis Prettier is failing. |
|
iOS seems to have the same bug as in the original issue: ios-app-2025-04-01_16.35.02.mp4 |
@jjcoffee The original issue is in regards to android, therefore the fix in this PR is focusing on android platform. Do we need another task for iOS? when can we merge this PR? |
|
@zirgulis I think QA may just not have tested on all platforms. If the fix has the same RCA, we might be better off doing it in this PR, but if it's more complicated I agree it could be a followup. |
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 for Android 👍
Approving to get a CME assigned to see whether or not we should create a separate issue to fix iOS, since it wasn't brought up in the original issue, and this has dragged on for a while already! cc @cead22
|
We did not find an internal engineer to review this PR, trying to assign a random engineer to #57734 as well as to this PR... Please reach out for help on Slack if no one gets assigned! |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
Whoops ok I just read all the comments. I think it's up to you if you wanna fix iOS in this PR. That's what I'd recommend but not opposed to doing it in a separate PR |
| const contentMaxHeight = measureHeightOfSuggestionRows(suggestionsLength, true); | ||
| const contentMinHeight = measureHeightOfSuggestionRows(suggestionsLength, false); | ||
| let bottomValue = windowHeight - (cursorCoordinates.y - scrollValue + y) - keyboardHeight; | ||
|
|
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.
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.
Fixed
| const StyleUtils = useStyleUtils(); | ||
| const styles = useMemo(() => StyleUtils.getBaseAutoCompleteSuggestionContainerStyle({left, width, bottom: bottom + getBottomSuggestionPadding()}), [StyleUtils, left, width, bottom]); | ||
| const bottomPadding = Platform.OS === 'android' ? (getBottomSuggestionPadding as GetBottomSuggestionPaddingAndroid)(bottom) : getBottomSuggestionPadding(); | ||
|
|
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.
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.
Fixed
| function AutoCompleteSuggestionsPortal<TSuggestion>({left = 0, width = 0, bottom = 0, resetSuggestions = () => {}, ...props}: AutoCompleteSuggestionsPortalProps<TSuggestion>) { | ||
| const StyleUtils = useStyleUtils(); | ||
| const styles = useMemo(() => StyleUtils.getBaseAutoCompleteSuggestionContainerStyle({left, width, bottom: bottom + getBottomSuggestionPadding()}), [StyleUtils, left, width, bottom]); | ||
| const bottomPadding = Platform.OS === 'android' ? (getBottomSuggestionPadding as GetBottomSuggestionPaddingAndroid)(bottom) : getBottomSuggestionPadding(); |
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.
I thought we weren't supposed to do this Platform.OS === 'android'. Is this allowed in index.native.tsx files?
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.
@cead22 I think in this case it's ok to have this check since the platform-specific difference is minimal. Creating a separate index.ios.tsx would result in significant code duplication
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.
Why's that? We're already importing getBottomSuggestionPadding, can't we make that platform specific?
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.
@cead22 getBottomSuggestionPadding is platform specific, but we pass bottom param only to the android version of getBottomSuggestionPadding, therefore there's Platform.OS === 'android' check
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.
Can we create a getBottomSuggestionPadding for ios and use that here? If not, can you elaborate on why we'd need a lot of duplicate code?
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.
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.
Could we pass the param to the iOS function and do nothing with it, so we can simplify this code?
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.
|
@jjcoffee @cead22 regarding the iOS: we should create a separate task for that. I checked last week what's going on iOS and the fix might not be so straightforward and might affect other platforms. For iOS the issue is when the |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/cead22 in version: 9.1.26-0 🚀
|
|
Failing on iOS with original bug id #57734 |
|
@kavimuru That is unrelated to the original issue as it only deals with Android. Is there an existing issue for this, or can we create one to track the iOS version of this problem? |
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.1.26-10 🚀
|


Explanation of Change
On Android devices, when editing mentions in a room chat, there is a large space displayed between the mention suggestions popup and the composer. This gap is inconsistent across different Android devices, with some devices (particularly Pixel phones) showing a significantly larger gap than others (like Samsung devices).
Implement an adaptive solution in
getBottomSuggestionPadding/index.android.tsthat calculates appropriate padding based on the device's aspect ratio.Fixed Issues
$ #57734
PROPOSAL: #57734 (comment)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop