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

Hide mobile Search nav button + status tabs on scrollDown, but reveal on scrollUp #48258

Open
wants to merge 41 commits into
base: main
Choose a base branch
from

Conversation

SzymczakJ
Copy link
Contributor

@SzymczakJ SzymczakJ commented Aug 29, 2024

Details

This PR adds an animation that hides mobile Search nav bar on scroll down and reveals it on scrollUp. Please note that this feature is only meant to work on mobile screens. Also when user doesn't have enough expenses, the bar won't hide.

Fixed Issues

$ #48019
PROPOSAL:

Tests

  1. Go to Search tab that has a lot of expenses.
  2. Try scrolling and make sure expense type and status bar hides and shows properly.
  3. Go to Search tab that has little or no expenses.
  4. Make sure and make sure expense type and status bar is locked in place.

Offline tests

QA Steps

Same as test steps

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android.mov
Android: mWeb Chrome
androidweb.mov
iOS: Native
ios.mov
iOS: mWeb Safari
iosweb.mov
MacOS: Chrome / Safari Screenshot 2024-08-30 at 10 37 31
MacOS: Desktop Screenshot 2024-08-30 at 10 42 31

Copy link
Contributor

@Guccio163 Guccio163 left a comment

Choose a reason for hiding this comment

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

generally LGTM, works great! 👀

Copy link
Contributor

@Kicu Kicu left a comment

Choose a reason for hiding this comment

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

Hey very nice work both on animation and refactoring. SearchPageHeader feels much simpler, and also Search component also looks simpler.

My only real problem is with SearchPageBottom because it became harder to read.
Most of my comments are minor naming issues, LGTM otherwise 👍

src/pages/Search/SearchPageBottomTab.tsx Outdated Show resolved Hide resolved
src/components/Search/index.tsx Outdated Show resolved Hide resolved
src/components/Search/SearchStatusBar.tsx Outdated Show resolved Hide resolved
isCustomQuery: boolean;
setOfflineModalOpen?: () => void;
setDownloadErrorModalOpen?: () => void;
data?: TransactionListItemType[] | ReportListItemType[];
Copy link
Contributor

Choose a reason for hiding this comment

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

great job removing so many props! 👏

src/components/Search/index.tsx Outdated Show resolved Hide resolved
src/components/Search/index.tsx Outdated Show resolved Hide resolved
src/components/SelectionList/index.tsx Outdated Show resolved Hide resolved
src/libs/SearchUtils.ts Outdated Show resolved Hide resolved
hash={queryJSON.hash}
isCustomQuery={isCustomQuery}
/>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think its possible to somehow simplify this and reduce the amount of conditional rendering inside this return?
We have conditional rendering for TopBar + SearchTypeMenu, then extra condition for SearchStatusBar and all that is exclusive with SearchPageHeader rendering.
It's very hard to understand which parts of the UI will be rendered.

Some ideas:

  • early returns?
  • saving parts of JSX to variables?
  • small helper components declared within this file?

I think you could try to go over this code again and see if anything can be improved.

@SzymczakJ SzymczakJ marked this pull request as ready for review September 4, 2024 09:05
@SzymczakJ SzymczakJ requested review from a team as code owners September 4, 2024 09:05
@melvin-bot melvin-bot bot requested review from rayane-djouah and removed request for a team September 4, 2024 09:06
Copy link

melvin-bot bot commented Sep 4, 2024

@rayane-djouah Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@shawnborton
Copy link
Contributor

Running a test build for easier testing...

This comment has been minimized.

@shawnborton
Copy link
Contributor

Any idea how to fix the iOS build above so we can test?

@SzymczakJ
Copy link
Contributor Author

I merged main and the error should be solved(ruby-version file was missing, but it was reintroduced after merge). Can you try again?

@shawnborton
Copy link
Contributor

Will do!

Copy link
Contributor

github-actions bot commented Sep 4, 2024

🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪

Android 🤖 iOS 🍎
https://ad-hoc-expensify-cash.s3.amazonaws.com/android/48258/index.html https://ad-hoc-expensify-cash.s3.amazonaws.com/ios/48258/index.html
Android iOS
Desktop 💻 Web 🕸️
https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/48258/NewExpensify.dmg https://48258.pr-testing.expensify.com
Desktop Web

👀 View the workflow run that generated this build 👀

@dannymcclain
Copy link
Contributor

I think this is feeling pretty darn good!

@SzymczakJ
Copy link
Contributor Author

I messed something up with merging. Will fix it in 5 minutes.
What about the thing that Jon said? @shawnborton

@shawnborton
Copy link
Contributor

I addressed Jon's comment above. Let's see what Danny thinks. I don't mind how it is working now though, I could totally get down with it's current behavior.

@SzymczakJ
Copy link
Contributor Author

@dannymcclain we need your opinion here! 😄

@dannymcclain
Copy link
Contributor

🫣 I kinda like the quick appear. But I will also add that I don't think there's a right answer here—both behaviors are totally totally valid. Like Shawn noted, I've seen and used both behaviors out in the wild and neither are "bad".

@dubielzyk-expensify if you feel strongly about changing the incoming animation, I am totally good with that. I don't feel insanely strongly because like I said, I think both approaches are good. If we want to get this behavior merged as is and come back to it, that's totally fine too.

What I like about the quick appear is that (for me personally) I'm likely scrolling up to get to those options, so getting them in front of me quickly is nice. I think I've also mentioned this before, but the quick appear also (again, for me) signals that this menu is being overlaid on top of the list and is not part of the list. So I know there's more expenses "under" it if I keep scrolling up.

@dannymcclain
Copy link
Contributor

lol ask and you shall receive! 😁

CleanShot 2024-09-17 at 08 38 48@2x

@dubielzyk-expensify
Copy link
Contributor

I'm happy to move forward with this 😄

@SzymczakJ
Copy link
Contributor Author

Nice! Then this is ready for your review @rayane-djouah

@luacmartins
Copy link
Contributor

Nice! It's looking really good. @rayane-djouah let's start reviewing this one

@rayane-djouah
Copy link
Contributor

Will review this first thing in my morning

src/components/Search/SearchContext.tsx Outdated Show resolved Hide resolved
src/components/Search/SearchContext.tsx Outdated Show resolved Hide resolved
src/components/Search/SearchPageHeader.tsx Outdated Show resolved Hide resolved
src/components/Search/index.tsx Outdated Show resolved Hide resolved
@@ -27,18 +27,20 @@ function SelectionList<TItem extends ListItem>(props: BaseSelectionListProps<TIt
};
}, []);

const defaultOnScroll = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const defaultOnScroll = () => {
const dismissKeyboard = () => {

src/components/Search/SearchContext.tsx Outdated Show resolved Hide resolved
@@ -3610,6 +3610,14 @@ const styles = (theme: ThemeColors) =>
fontWeight: FontUtils.fontWeight.bold,
},

This comment was marked as resolved.

src/pages/Search/SearchPageBottomTab.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's rename the file to SearchSelectionModeHeader.tsx

import SearchTypeMenu from './SearchTypeMenu';

const TOO_CLOSE_TO_TOP_DISTANCE = 5;
const TOO_CLOSE_TO_BOTTOM_DISTNACE = 10;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const TOO_CLOSE_TO_BOTTOM_DISTNACE = 10;
const TOO_CLOSE_TO_BOTTOM_DISTANCE = 10;

Copy link
Contributor

Choose a reason for hiding this comment

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

We still have this typo 😄

Copy link
Contributor

Choose a reason for hiding this comment

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

Bug on small screens: Selected multiple expenses and clicked "delete," but the delete confirmation modal did not appear.

Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2024-09-19.at.23.02.42.mp4

Copy link
Contributor

@rayane-djouah rayane-djouah left a comment

Choose a reason for hiding this comment

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

Bug: The app crash on Android native when we open the search page:

Screenshot

Screenshot_20240919-233339.png

@SzymczakJ
Copy link
Contributor Author

fixed your comments @rayane-djouah!

}
Keyboard.dismiss();
}}
onScroll={onScroll ?? defaultOnScroll}
Copy link
Contributor

@rayane-djouah rayane-djouah Sep 20, 2024

Choose a reason for hiding this comment

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

@SzymczakJ Can we use dismissKeyboard in onScrollBeginDrag and our custom onScroll in onScroll?

import SearchTypeMenu from './SearchTypeMenu';

const TOO_CLOSE_TO_TOP_DISTANCE = 5;
const TOO_CLOSE_TO_BOTTOM_DISTNACE = 10;
Copy link
Contributor

Choose a reason for hiding this comment

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

We still have this typo 😄

@rayane-djouah
Copy link
Contributor

Bug: Status bar is not scrollable on the Android native app

@rayane-djouah
Copy link
Contributor

Bug: We have some spacing inconsistency:

Staging Dev (This PR)
The status bar has a 20px bottom margin The status bar has an 8px bottom margin
Screenshot 2024-09-21 at 4 34 30 PM Screenshot 2024-09-21 at 4 34 34 PM
Screenshot 2024-09-21 at 4 34 30 PM Screenshot 2024-09-21 at 4 34 34 PM
Staging Dev (This PR)
The skeleton list doesn't have a top margin, and the status bar has a 20px bottom margin The skeleton list has a 12px top margin, and the status bar has an 8px bottom margin, this causes the empty state view to move 8px to the top
Screenshot 2024-09-21 at 4 34 13 PM Screenshot 2024-09-21 at 4 34 07 PM
Staging Dev (This PR)
The skeleton list doesn't have a top margin, and the status bar has a 20px bottom margin The skeleton list has a 12px top margin, and the status bar has a 20px bottom margin => 32px total
Screenshot 2024-09-21 at 4 04 18 PM Screenshot 2024-09-21 at 3 51 11 PM

@rayane-djouah
Copy link
Contributor

Not sure which one is correct:

Staging Dev (This PR)
The status bar is displayed in the selection mode The status bar is not displayed in the selection mode
Screenshot 2024-09-21 at 5 14 09 PM Screenshot 2024-09-21 at 5 13 38 PM

@SzymczakJ
Copy link
Contributor Author

Not sure which one is correct:

We've agreed upon second version here #48019 (comment)

@SzymczakJ
Copy link
Contributor Author

SzymczakJ commented Sep 23, 2024

Fixed your comments @rayane-djouah!
PS. Awesome review 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants