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

Update SearchPageHeaderInput to display recent search and chats #53198

Merged

Conversation

Kicu
Copy link
Member

@Kicu Kicu commented Nov 27, 2024

Explanation of Change

This PR refactors SearchPageHeaderInput and SearchRouter, to put all (expect contextual search) Router features into the Input on Search results.
Also when cmd+k shortcut is used while on Search Results Page, then we will focus on the Input and not show the Router.

Fixed bugs

Other things

  1. I was unable to properly fix box height: Use autocomplete on Search Results Header #52568 (comment) The reason is that I believe this is a problem deeper in the SelectionList. I played with different styles, max-heights etc and none of this changed the behavior.
    I'm providing a video which shows that from the perspective of Search list components there is exactly 1 render, which introduces all the items, and there is nothing weird happening with data lengths. Thus the source of the flicker is most likely inside SelectionList, and I'd prefer to not change this list in this PR
flicker with console logs of renders
rec-web-list-flicker.mp4
2. Keyboard navigation will sometimes jump out from suggestions the Search results below. This happens only when we have 1 item in the list, and so I think it should not be a big problem. The source lies much deeper in the code, because `SelectionList` simply always attaches a global keyboard handler for arrows UP/DOWN, and is not ready to work in cases where there are 2 lists. Source: https://github.com/Expensify/App/blob/main/src/components/SelectionList/BaseSelectionList.tsx#L317 This is a bigger problem that should be solved in a separate issue IMO.

Fixed Issues

$ #53126
PROPOSAL:

Tests

  • verify that cmd+k will focus Input when on Search results page
  • verify that the Input on Search results page has the same items as Router
  • verify you can navigate from Search results page to a chat via list items

Offline tests

QA Steps

Same as Tests

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 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 used JaimeGPT to get English > Spanish translation. I then posted it 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.ts 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.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • 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: mWeb Chrome Android focus bug fix
rec-andr-focus-bug.mp4
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
rec-search-web.mp4
MacOS: Desktop

@luacmartins luacmartins self-requested a review November 27, 2024 16:03
@Kicu Kicu force-pushed the kicu/search-results-input branch from 8e813c9 to 4ee583b Compare November 28, 2024 15:04
@Kicu Kicu force-pushed the kicu/search-results-input branch 2 times, most recently from 549ff19 to 3b68543 Compare December 2, 2024 08:53
@Kicu Kicu marked this pull request as ready for review December 2, 2024 11:29
@Kicu Kicu requested a review from a team as a code owner December 2, 2024 11:29
@melvin-bot melvin-bot bot requested review from rojiphil and removed request for a team December 2, 2024 11:29
Copy link

melvin-bot bot commented Dec 2, 2024

@rojiphil 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]

@Kicu Kicu force-pushed the kicu/search-results-input branch from 3b68543 to fc50688 Compare December 2, 2024 11:30
@rojiphil
Copy link
Contributor

rojiphil commented Dec 2, 2024

Reviewing now

@Kicu
Copy link
Member Author

Kicu commented Dec 2, 2024

@rojiphil I have pushed 1 additional commit with the changes suggested by @blazejkustra

@rojiphil
Copy link
Contributor

rojiphil commented Dec 2, 2024

@rojiphil I have pushed 1 additional commit with the changes suggested by @blazejkustra

Thanks @Kicu for the update.

if the query is empty, the first item on the list will also be empty, and will navigate to default search

The above-mentioned case is implemented for Search Results Page but is not there for SearchRouter. In SearchRouter though, the initial focus is on the most recent chat. Further, on clearing the input, the focus moves to the most recent search. Don’t we have to make this consistent with the Search Results Page behavior?
Here is a video demonstrating this:

53198-initialquery-issue.mp4

@Kicu
Copy link
Member Author

Kicu commented Dec 2, 2024

Yes you're right, thanks for pointing this out.
Basically two things happened:

  • for SearchRouter someone created an issue requesting the functionality of first recent report being focused, and it was implemented
  • for Search Results Page we discussed on slack that it would be nice to have the functionality of basically resetting/dropping current query, hence I added the empty first item

I think it makes some sense because if you're on /search page you always have some query and some results, so from there it may be useful to navigate to default search.
Whereas Router can be accessed from anywhere and so the option to clean current query might not (always) make sense there.

But it could be considered confusing. Do you have any thought @luacmartins ?

@luacmartins
Copy link
Contributor

This is an interesting case. I think the empty first item is confusing. I'd just remove it to make it consistent with the router.

@Kicu Kicu changed the title [WIP] Update SearchPageHeaderInput to display recent search and chats Update SearchPageHeaderInput to display recent search and chats Dec 3, 2024
@Kicu
Copy link
Member Author

Kicu commented Dec 3, 2024

Ok I will remove the empty item, however there was a convo about this here: https://swmansion.slack.com/archives/C06ML6X0W9L/p1732623340138529, and Vit suggested it's confusing for him.

@Kicu Kicu force-pushed the kicu/search-results-input branch from bb85e0e to 9675b9c Compare December 3, 2024 11:03
@Kicu
Copy link
Member Author

Kicu commented Dec 3, 2024

@rojiphil I added the change suggested by Carlos (no empty item), and fixed newest conflicts with main. I did a rebase instead of merge by mistake - sorry about that.
There was a PR merged that touched both SearchRouter and Input so small things changed there.
Can you take another look?

@luacmartins
Copy link
Contributor

luacmartins commented Dec 3, 2024

@rojiphil let's prioritize reviewing this PR once you're available

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

Looking really good. I just noticed one small bug.

  1. Navigate to a report
  2. Open the search router (cmd+k)
  3. Notice that Search in... is at the bottom of the list

Screenshot 2024-12-03 at 10 47 03 AM

@@ -124,6 +136,7 @@ function SearchPageHeaderInput({queryJSON, children}: SearchPageHeaderInputProps
return;
}

// TODO remove special handling of policyID after navigation is merged https://github.com/Expensify/App/pull/49539
Copy link
Contributor

Choose a reason for hiding this comment

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

I created an issue for this. Let's remove the comment - #53480

Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

Looks good. Only issue left is #53198 (comment). I think we're in a good spot to get this merged tomorrow.

@Kicu
Copy link
Member Author

Kicu commented Dec 5, 2024

FYI this bug is quite tricky, and it does not always reproduce - it only appears if user has entered the search page more than once. I'm working on it but I don't yet have a solution, there's something wonky happening with navigation + ref to the input.

@Kicu
Copy link
Member Author

Kicu commented Dec 5, 2024

@luacmartins @rojiphil the bug ended up being veeeery tricky, connected to how navigation mounts and unmounts screens, and when they run their useEffect.
I believe I have it fixed now. Please verify if it works on your end

rec-focus.mp4

@rojiphil
Copy link
Contributor

rojiphil commented Dec 5, 2024

yeah that was a nasty one but looks like it's fixed. Working on the checklist now

@rojiphil
Copy link
Contributor

rojiphil commented Dec 5, 2024

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible 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 checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified tests pass on all platforms & I tested again on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (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 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
    • 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 verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • 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.ts or at the top of the file that uses the constant) are defined as such
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • 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.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • 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.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

MacOS: Chrome / Safari
53198-web-safari-003.mp4
MacOS: Desktop
53198-desktop-003.mp4
Android: Native
53198-android-native-003.mp4
Android: mWeb Chrome
53198-mweb-chrome-003.mp4
iOS: Native
53198-ios-native-004.mp4
iOS: mWeb Safari
53198-mweb-safari-003.mp4

Copy link
Contributor

@rojiphil rojiphil left a comment

Choose a reason for hiding this comment

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

Thanks @Kicu for the fix.

Code LGTM and works well too.
@luacmartins All yours for review. Thanks.

@melvin-bot melvin-bot bot requested a review from luacmartins December 5, 2024 17:02
Copy link
Contributor

@luacmartins luacmartins left a comment

Choose a reason for hiding this comment

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

LGTM.

@luacmartins
Copy link
Contributor

Awesome job on this one!

@luacmartins luacmartins merged commit fb8be4d into Expensify:main Dec 5, 2024
17 checks passed
@OSBotify
Copy link
Contributor

OSBotify commented Dec 5, 2024

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

Copy link
Contributor

github-actions bot commented Dec 9, 2024

🚀 Deployed to staging by https://github.com/luacmartins in version: 9.0.73-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅
🤖🔄 android HybridApp 🤖🔄 success ✅
🍎🔄 iOS HybridApp 🍎🔄 failure ❌

@izarutskaya
Copy link

Found KI on mWeb only - issue #53783

Copy link
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 9.0.73-8 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅
🤖🔄 android HybridApp 🤖🔄 success ✅
🍎🔄 iOS HybridApp 🍎🔄 success ✅

@ikevin127
Copy link
Contributor

This had a regression:

which was confirmed by author in follow-up PR #53859 description.

@rojiphil
Copy link
Contributor

Agree that was a regression. But we addressed multiple issues at once here and there was quite a lot of quality work that went into the PR.
@luacmartins Can we not avoid the penalising clause here and keep the default compensation instead?

@rojiphil
Copy link
Contributor

This had a regression:

@ikevin127 Yeah, and next time, please tag me also for regression issues where I am the original PR reviewer and as mentioned in the C+ Process Doc here. Thanks.

@ikevin127
Copy link
Contributor

Can we not avoid the penalising clause here and keep the default compensation instead?

I concur that we should not avoid the penalty as this would set a precedent for both past / future issues, when the rules are clear on regressions regardless of how many test cases were included in PR description (as long as they were included).

Yeah, and next time, please tag me also for regression issues where I am the original PR reviewer

Sure, I'll try to be more careful next time - hopefully will not get a penalty for this 🤕

@rojiphil
Copy link
Contributor

I concur that we should not avoid the penalty as this would set a precedent for both past / future issues, when the rules are clear on regressions regardless of how many test cases were included in PR description (as long as they were included).

Oh! What I meant is that as per the process, there is a provision to increase the compensation when there is more work involved. And usually, I take this up at the time of payment considering the entire issue holistically.
So, what I meant is to increase the compensation and apply the penalty so that it comes back to the default compensation. My intention was not to avoid the process as I agree that it would then set a precedent.

@ikevin127
Copy link
Contributor

And usually, I take this up at the time of payment considering the entire issue holistically.

So, what I meant is to increase the compensation and apply the penalty so that it comes back to the default compensation.

I don't think it matters how you word it, it's the same thing since you are only asking for increase after the regression was brought to your attention, not before you started the review, considering the entire issue holistically as you said.

Not sure what the procedure is on issues that don't have a set price, as far as I know it's $250 unless an increase was asked for, justfied and granted before starting the PR review (at least that would make sense to me), during issue / proposal review.

Maybe I'm missing something though!

@rojiphil
Copy link
Contributor

@ikevin127 As per the process, I think it's incorrect to say unless an increase was asked for, justfied and granted **before** starting the PR review. Perhaps you missed reading this section and this one too within the C+ process doc.

@luacmartins
Copy link
Contributor

I think it's fine to keep the original amount in this case given the workload for the original issue.

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.

7 participants