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

[$250] Android - Distance - Previous waypoints displayed for a second before new suggestions appear #48643

Closed
1 of 6 tasks
lanitochka17 opened this issue Sep 5, 2024 · 37 comments
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Monthly KSv2 Reviewing Has a PR in review

Comments

@lanitochka17
Copy link

lanitochka17 commented Sep 5, 2024

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Version Number: 9.0.29-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: https://expensify.testrail.io/index.php?/tests/view/4923199&group_by=cases:section_id&group_order=asc&group_id=309127
Issue reported by: Applause - Internal Team

Action Performed:

  1. Open the Expensify app
  2. Tap on the FAB
  3. Tap on "Submit Expense"
  4. Tap on "Distance"
  5. Tap on "Start" point
  6. Write one letter of the searched direction
  7. Check the suggestions behaviour
  8. Write another letter
  9. Check the suggestions behaviour again
  10. Tap on "Stop" point
  11. Repeat steps 6-9

Expected Result:

When the user starts writing a new waypoint, all the related suggestions should be displayed automatically

Actual Result:

When user starts writing a new waypoint, with each new letter, previously used directions appear for a second before all the related suggestions are displayed

Workaround:

Unknown

Platforms:

Which of our officially supported platforms is this issue occurring on?

  • Android: Native
  • Android: mWeb Chrome
  • iOS: Native
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

Add any screenshot/video evidence

Bug6592945_1725458793387.Distance_Suggestions.mp4

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021832156095103318812
  • Upwork Job ID: 1832156095103318812
  • Last Price Increase: 2024-09-13
  • Automatic offers:
    • nyomanjyotisa | Contributor | 104055859
Issue OwnerCurrent Issue Owner: @ntdiary
@lanitochka17 lanitochka17 added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 5, 2024
Copy link

melvin-bot bot commented Sep 5, 2024

Triggered auto assignment to @puneetlath (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

@lanitochka17
Copy link
Author

@puneetlath FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors

@FitseTLT
Copy link
Contributor

FitseTLT commented Sep 5, 2024

Edited by proposal-police: This proposal was edited at 2024-09-05 13:31:17 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Android - Distance - Previous waypoints displayed for a second before new suggestions appear

What is the root cause of that problem?

We are displaying the predefined places even in online case here until the search suggestion result comes from google place auto complete

const filteredPredefinedPlaces = useMemo(() => {
if (!searchValue) {
return predefinedPlaces ?? [];
}
return predefinedPlaces?.filter((predefinedPlace) => isPlaceMatchForSearch(searchValue, predefinedPlace)) ?? [];

What changes do you think we should make in order to solve the problem?

We need to show the predefined places only for offline case so change it to

 const filteredPredefinedPlaces = useMemo(() => {
        if (!isOffline) {
            return [];
        }
        if (!searchValue) {
            return predefinedPlaces ?? [];
        }
        return predefinedPlaces?.filter((predefinedPlace) => isPlaceMatchForSearch(searchValue, predefinedPlace)) ?? [];
    }, [predefinedPlaces, searchValue, isOffline]);

What alternative solutions did you explore? (Optional)

We can also do

predefinedPlaces={filteredPredefinedPlaces}

                        predefinedPlaces={isOffline ? filteredPredefinedPlaces : []}

or we can set predefinedPlacesAlwaysVisible to true if we want to always show the predefined places

@nyomanjyotisa
Copy link
Contributor

nyomanjyotisa commented Sep 5, 2024

Edited by proposal-police: This proposal was edited at 2024-09-12 00:31:47 UTC.

Proposal

Please re-state the problem that we are trying to solve in this issue.

Distance - Previous waypoints displayed for a second before new suggestions appear

What is the root cause of that problem?

if the searchValue is not empty we display the filtered predefinedPlaces in both online and offline

const filteredPredefinedPlaces = useMemo(() => {
if (!searchValue) {
return predefinedPlaces ?? [];
}
return predefinedPlaces?.filter((predefinedPlace) => isPlaceMatchForSearch(searchValue, predefinedPlace)) ?? [];
}, [predefinedPlaces, searchValue]);

What changes do you think we should make in order to solve the problem?

If searchValue exist and is online and also is typing, don't show any predefinedPlaces. And if searchValue is empty we still need to display the predefinedPlaces even in online mode

And we only need to rerender filteredPredefinedPlaces once searchValue changed or on onInputChange to prevent this issue

Create new const

const [shouldHidePredefinedPlaces, setShouldHidePredefinedPlaces] = useState(false);

Change this code to the following

    const filteredPredefinedPlaces = useMemo(() => {
        if (!searchValue) {
            return predefinedPlaces ?? [];
        } else if (shouldHidePredefinedPlaces) {
            return [];
        }
        return predefinedPlaces?.filter((predefinedPlace) => isPlaceMatchForSearch(searchValue, predefinedPlace)) ?? [];
    }, [predefinedPlaces, searchValue]);

Then add the following code on onInputChange here

if(isOffline){
    setShouldHidePredefinedPlaces(false)
}else{
    setShouldHidePredefinedPlaces(true)
}

or just this

setShouldHidePredefinedPlaces(!isOffline)

What alternative solutions did you explore? (Optional)

Create a new const

const [shouldHidePredefinedPlaces, setShouldHidePredefinedPlaces] = useState(false);

If searchValue exist and is online and also shouldHidePredefinedPlaces, don't show any predefinedPlaces. And if searchValue is empty we still need to display the predefinedPlaces even in online mode

    const filteredPredefinedPlaces = useMemo(() => {
        if (!searchValue) {
            return predefinedPlaces ?? [];
        } else if (!isOffline && shouldHidePredefinedPlaces) {
            return [];
        }

        return predefinedPlaces?.filter((predefinedPlace) => isPlaceMatchForSearch(searchValue, predefinedPlace)) ?? [];
    }, [predefinedPlaces, searchValue]);

onInputChange here we should set setShouldHidePredefinedPlaces to true

We should setShouldHidePredefinedPlaces to false if isOffline changed

    useEffect(() => {
        setShouldHidePredefinedPlaces(false)
    }, [isOffline]);

@Shahidullah-Muffakir
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

When the user starts typing a new location in the app, they briefly see old locations they've used before, but then those disappear and get replaced by new suggested locations from the map service. This can be confusing for the user because:

  1. The old locations flash on the screen for just a second before going away, so the user doesn't have time to actually select them.
  2. It's not clear why those old locations are being shown at all, since the user can't use them.
    That is why I think we should hide them.

What is the root cause of that problem?

The app is always showing predefined locations (previously used by the user) regardless of whether the user is offline or online. This behavior is not ideal when the user is online and actively typing in a new location.

What changes do you think we should make in order to solve the problem?

When the user is online, only show the predefined locations if they haven't started typing anything in the input box yet. As soon as the user starts typing, stop showing the previously used locations and instead display the recommended locations fetched from the map provider's live API.
However, if the user is offline, always show the predefined locations whether they have typed anything or not, since these are the only locations the user can select from in offline mode.

const filteredPredefinedPlaces = useMemo(() => {


if (!isOffline && searchValue) {
  return [];
}

This will ensure that when the user is online and has started typing, an empty array is returned, preventing the previously used locations from being displayed.

Screen.20Recording.202024-09-05.20at.207.mp4

@bernhardoj
Copy link
Contributor

Proposal

Please re-state the problem that we are trying to solve in this issue.

Saved waypoints are shown briefly when searching address.

What is the root cause of that problem?

When we search, the search keyword state is updated which recalculate the predefined places.

const filteredPredefinedPlaces = useMemo(() => {
if (!searchValue) {
return predefinedPlaces ?? [];
}
return predefinedPlaces?.filter((predefinedPlace) => isPlaceMatchForSearch(searchValue, predefinedPlace)) ?? [];
}, [predefinedPlaces, searchValue]);

When the predefined places are updated, the auto complete component will update the list with the new predefined places and pass an empty result to it.
https://github.com/FaridSafi/react-native-google-places-autocomplete/blob/ef107387c6846924423b832a242eee83cb07eed4/GooglePlacesAutocomplete.js#L176-L179

Because the result is empty, the predefined places are shown.
https://github.com/FaridSafi/react-native-google-places-autocomplete/blob/ef107387c6846924423b832a242eee83cb07eed4/GooglePlacesAutocomplete.js#L91-L102

After the search is completed, the list is updated again with the new result.

What changes do you think we should make in order to solve the problem?

We need to pass the result when updating the list.
https://github.com/FaridSafi/react-native-google-places-autocomplete/blob/ef107387c6846924423b832a242eee83cb07eed4/GooglePlacesAutocomplete.js#L176-L179

There is already a variable that stores the last result here, but it's not a ref, so the value is always gone after re-render, so we need to convert it to ref too.

useEffect(() => {
  // Update dataSource if props.predefinedPlaces changed
  setDataSource(buildRowsFromResults(_results.current));
}, [buildRowsFromResults, props.predefinedPlaces]);

What alternative solutions did you explore? (Optional)

Never show saved waypoints (predefined places) when searching.

const filteredPredefinedPlaces = useMemo(() => {
if (!searchValue) {
return predefinedPlaces ?? [];
}
return predefinedPlaces?.filter((predefinedPlace) => isPlaceMatchForSearch(searchValue, predefinedPlace)) ?? [];
}, [predefinedPlaces, searchValue]);

@puneetlath puneetlath added the External Added to denote the issue can be worked on by a contributor label Sep 6, 2024
@melvin-bot melvin-bot bot changed the title Android - Distance - Previous waypoints displayed for a second before new suggestions appear [$250] Android - Distance - Previous waypoints displayed for a second before new suggestions appear Sep 6, 2024
Copy link

melvin-bot bot commented Sep 6, 2024

Job added to Upwork: https://www.upwork.com/jobs/~021832156095103318812

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 6, 2024
Copy link

melvin-bot bot commented Sep 6, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @ntdiary (External)

@ntdiary
Copy link
Contributor

ntdiary commented Sep 9, 2024

We need to show the predefined places only for offline case

Hi, @FitseTLT, curious is there any doc supporting this requirement? I feel it would also be good to display predefined places if the searchValue is empty? 🤔

@FitseTLT
Copy link
Contributor

FitseTLT commented Sep 9, 2024

We need to show the predefined places only for offline case

Hi, @FitseTLT, curious is there any doc supporting this requirement? I feel it would also be good to display predefined places if the searchValue is empty? 🤔

Maybe let's ask @puneetlath for Internal thoughts 👍

@ntdiary
Copy link
Contributor

ntdiary commented Sep 10, 2024

Hi, @lanitochka17, @puneetlath, I have a question about the expect result, should the related recent destinations be displayed in the suggestion list? Could you please confirm this point? (e.g., The Home place in my screenshot)
image

@puneetlath
Copy link
Contributor

I think we should show them when the composer is empty and when offline. I think once you start typing, it's fine for us to just use whatever results the maps API thinks is the most relevant to your search. Which I would assume can also include the pre-defined places.

@Shahidullah-Muffakir
Copy link
Contributor

I think we should show them when the composer is empty and when offline. I think once you start typing, it's fine for us to just use whatever results the maps API thinks is the most relevant to your search. Which I would assume can also include the pre-defined places.

@puneetlath Based on your input, I believe my proposal aligns well with the requirements you've outlined, particularly regarding showing suggestions when the composer is empty (whether online or offline) and when offline (at all times)
My Proposal: #48643 (comment)
Thank you.

@ntdiary
Copy link
Contributor

ntdiary commented Sep 11, 2024

I think we should show them when the composer is empty and when offline. I think once you start typing, it's fine for us to just use whatever results the maps API thinks is the most relevant to your search. Which I would assume can also include the pre-defined places.

Based on this input, @nyomanjyotisa's solution is the first to meet the requirements. Additionally, there's a minor edge case with this solution: if we start typing while offline, the filtered predefined places will be shown, but when switching back online, no suggestions will appear. In the production app, the filtered predefined places will still be displayed.

test.mp4

@puneetlath
Copy link
Contributor

Hmm. Is there any way to have that not be the case?

@nyomanjyotisa
Copy link
Contributor

I think we should show them when the composer is empty and when offline. I think once you start typing, it's fine for us to just use whatever results the maps API thinks is the most relevant to your search. Which I would assume can also include the pre-defined places.

Based on this input, @nyomanjyotisa's solution is the first to meet the requirements. Additionally, there's a minor edge case with this solution: if we start typing while offline, the filtered predefined places will be shown, but when switching back online, no suggestions will appear. In the production app, the filtered predefined places will still be displayed.

test.mp4

Updated my proposal to address this issue

-1-New-Expensify.24.mp4

@ntdiary
Copy link
Contributor

ntdiary commented Sep 13, 2024

a new edge issue:
if we go offline after start typing, the updated solution will show a filtered predefined places, while in production, our app will still show the search results. 🤔

test.mp4

@nyomanjyotisa
Copy link
Contributor

nyomanjyotisa commented Sep 13, 2024

Proposal updated to address the original Issue, this issue, and also this issue

New-Expensify.30.mp4

@ntdiary
Copy link
Contributor

ntdiary commented Sep 13, 2024

another case:
After clearing the search value, the predefined places are not displayed 😂:

clear-case.mp4

Copy link

melvin-bot bot commented Sep 13, 2024

📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸

@nyomanjyotisa
Copy link
Contributor

another case: After clearing the search value, the predefined places are not displayed 😂:

clear-case.mp4

Predefined places are displayed after clearing the search value, make sure you try the main solution on my proposal

New-Expensify.31.mp4

@ntdiary
Copy link
Contributor

ntdiary commented Sep 14, 2024

Predefined places are displayed after clearing the search value, make sure you try the main solution on #48643 (comment)

I reinstalled the react-native-google-places-autocomplete package, and this edge case seems to have disappeared. However, from your video, I can still see that the predefined places flash for a moment before the loading appears. 🤔

Copy link

melvin-bot bot commented Sep 17, 2024

@puneetlath, @ntdiary Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Sep 17, 2024
Copy link

melvin-bot bot commented Sep 19, 2024

@puneetlath @ntdiary this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!

Copy link

melvin-bot bot commented Sep 19, 2024

@puneetlath, @ntdiary Huh... This is 4 days overdue. Who can take care of this?

@puneetlath
Copy link
Contributor

@ntdiary what's next here?

@ntdiary
Copy link
Contributor

ntdiary commented Sep 20, 2024

@ntdiary what's next here?

After re-investigating, I found that the previously mentioned flash was caused by the hiding of currentLocation, which is unrelated to @nyomanjyotisa's solution.

{/* This will show current location button in list if there are some recent destinations */}
{shouldShowCurrentLocationButton && (
<CurrentLocationButton
onPress={getCurrentLocation}
isDisabled={isOffline}
/>
)}
{!value && <Text style={[styles.textLabel, styles.colorMuted, styles.pv2, styles.ph3, styles.overflowAuto]}>{translate('common.recentDestinations')}</Text>}

image

This means their proposal is still reasonable, it's fine to move forward with their proposal! :)

🎀 👀 🎀 C+ reviewed

@melvin-bot melvin-bot bot removed the Overdue label Sep 20, 2024
Copy link

melvin-bot bot commented Sep 20, 2024

Current assignee @puneetlath is eligible for the choreEngineerContributorManagement assigner, not assigning anyone new.

@melvin-bot melvin-bot bot removed the Help Wanted Apply this label when an issue is open to proposals by contributors label Sep 20, 2024
Copy link

melvin-bot bot commented Sep 20, 2024

📣 @nyomanjyotisa 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app!

Offer link
Upwork job
Please accept the offer and leave a comment on the Github issue letting us know when we can expect a PR to be ready for review 🧑‍💻
Keep in mind: Code of Conduct | Contributing 📖

Copy link

melvin-bot bot commented Oct 16, 2024

This issue has not been updated in over 15 days. @puneetlath, @ntdiary, @nyomanjyotisa eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@puneetlath
Copy link
Contributor

What's the status with this? Is it ready to pay out?

@ntdiary
Copy link
Contributor

ntdiary commented Oct 17, 2024

The PR was deployed to production 3 weeks ago, but the automation here has failed, I will fill out the bug zero checklist. :)

@ntdiary
Copy link
Contributor

ntdiary commented Oct 17, 2024

BugZero Checklist: The PR fixing this issue has been merged! The following checklist will need to be completed before the issue can be closed:

Regression steps:

  1. Open the Expensify app
  2. Tap on the FAB
  3. Tap on "Submit Expense"
  4. Tap on "Distance"
  5. Tap on "Start" point
  6. If your address suggestion list is empty, please search for an address and save it. Repeat this step a few times to save multiple addresses.
  7. Tap on "Stop" point.
  8. Enter one letter from any of those previously saved addresses.
  9. Verify the previous filtered addresses won't display for a second before the new suggestions appear.

@puneetlath
Copy link
Contributor

Payment summary:

Thanks everyone!

@JmillsExpensify
Copy link

$250 approved for @ntdiary

@ntdiary
Copy link
Contributor

ntdiary commented Oct 25, 2024

image

Hi, @JmillsExpensify, app keeps prompting me that the Merchant is duplicated, not sure if this will affect approval. 😂

@JmillsExpensify
Copy link

Just ignore it, though I've already approved this payment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken. Auto assigns a BugZero manager. External Added to denote the issue can be worked on by a contributor Monthly KSv2 Reviewing Has a PR in review
Projects
No open projects
Status: Polish
Development

No branches or pull requests

8 participants