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 - Unable to switch distance label unit when tapping on the label #56499

Open
1 of 8 tasks
mvtglobally opened this issue Feb 7, 2025 · 23 comments
Open
1 of 8 tasks
Assignees
Labels
Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors

Comments

@mvtglobally
Copy link

mvtglobally commented Feb 7, 2025

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.95-0
Reproducible in staging?: Yes
Reproducible in production?: Unable to check (New feature)
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Yes, reproducible on both
If this was caught during regression testing, add the test name, ID and link from TestRail: #55517
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team
Device used: Samsung Galaxy Z Fold 4 / Android 14
App Component: Money Requests

Action Performed:

  1. Go to staging.new.expensify.com (web or mweb or iOS).
  2. Open FAB > Create expense > Distance.
  3. Enter start and stop waypoint.
  4. Tap on the distance label on the map.
  5. Note that the label will change from mile to kilometer or vice versa when tapped.
  6. Launch Android app.
  7. Open FAB > Create expense > Distance.
  8. Enter start and stop waypoint.
  9. Tap on the distance label on the map.

Expected Result:

The distance label will change from mile to kilometer or vice versa when tapped.

Actual Result:

The distance label does not change when tapped.

Workaround:

Unknown

Platforms:

  • Android: Standalone
  • Android: HybridApp
  • Android: mWeb Chrome
  • iOS: Standalone
  • iOS: HybridApp
  • iOS: mWeb Safari
  • MacOS: Chrome / Safari
  • MacOS: Desktop

Screenshots/Videos

https://utest-dl.s3-accelerate.amazonaws.com/12102/26469/491203/6735645/bugAttachment/Bug6735645_1738880567891%211738880241936_Screen_Recording_20250207_061628_Chrome.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20250207T020848Z&X-Amz-SignedHeaders=host&X-Amz-Credential=AKIAJ2UIWMJ2OMC3UCQQ%2F20250207%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Expires=86400&X-Amz-Signature=dac2a54db02eb81e8d48fdc8b2708d0e67edd5823ab77ff7be6674703f776af2

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~021887689540451729884
  • Upwork Job ID: 1887689540451729884
  • Last Price Increase: 2025-02-21
Issue OwnerCurrent Issue Owner: @abdulrahuman5196
@mvtglobally mvtglobally added Bug Something is broken. Auto assigns a BugZero manager. Daily KSv2 labels Feb 7, 2025
Copy link

melvin-bot bot commented Feb 7, 2025

Triggered auto assignment to @VictoriaExpensify (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.

@mvtglobally mvtglobally added the DeployBlockerCash This issue or pull request should block deployment label Feb 7, 2025
Copy link

melvin-bot bot commented Feb 7, 2025

Triggered auto assignment to @marcochavezf (DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.

Copy link

melvin-bot bot commented Feb 7, 2025

💬 A slack conversation has been started in #expensify-open-source

@github-actions github-actions bot added Engineering Hourly KSv2 and removed Daily KSv2 labels Feb 7, 2025
Copy link
Contributor

github-actions bot commented Feb 7, 2025

👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

  1. Identify the pull request that introduced this issue and revert it.
  2. Find someone who can quickly fix the issue.
  3. Fix the issue yourself.

@VictoriaExpensify VictoriaExpensify added the External Added to denote the issue can be worked on by a contributor label Feb 7, 2025
@melvin-bot melvin-bot bot changed the title Android - Distance - Unable to switch distance label unit when tapping on the label [$250] Android - Distance - Unable to switch distance label unit when tapping on the label Feb 7, 2025
Copy link

melvin-bot bot commented Feb 7, 2025

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

@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Feb 7, 2025
Copy link

melvin-bot bot commented Feb 7, 2025

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

@OmarKoueifi
Copy link
Contributor

Proposal

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

The issue occurs when attempting to toggle the distance label (miles ↔ kilometers) on Android. The tap event does not trigger correctly, preventing users from switching the unit.

What is the root cause of that problem?

The problem originates in the following code:

https://github.com/truph01/App/blob/5632ffda8f4781eed679d35c8acd159cc8295c7c/src/components/MapView/MapView.tsx#L315-L331

Checking the MarkerView code I saw

onTouchEnd={(e) => {
    e.stopPropagation();
}}
  • The MarkerView component uses onTouchEnd to stop event propagation.
  • This prevents the onPress event in the PressableWithoutFeedback component from triggering, as the event does not bubble up correctly.

Since this is a deploy blocker, I will begin preparing my PR and testing immediately.

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

  1. Replace onPress with onTouchEnd:
    • Since onPress is being blocked, switching to onTouchEnd ensures the event fires correctly.
  2. Verify behavior across platforms:
    • I tested this fix on Web, iOS, and Android, and it works as expected on all platforms.

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

When using pressable components PressableWithoutFeedback in the map view inside MarkerView component use onTouchEnd instead of onPress

  • Ensure clicking/tapping a marker triggers the expected event.
  • Verify that touch events propagate correctly without blocking interactions.
  • Ensure the fix works on Web (Safari and Chrome), iOS and Android (App and browser)

What alternative solutions did you explore? (Optional)

N/A

@OmarKoueifi
Copy link
Contributor

Screen recording form the fix:

Android app:

android.app.mov

Android chrome:

android.chrome.mov

iOS app:

iOS.App.mov

iOS safari:

iOS.safari.mov

Chrome Mac:

chrome.mov

Safari Mac:

safari.mov

MacOS app:

MacOS.desktop.app.mov

@melvin-bot melvin-bot bot added the Overdue label Feb 10, 2025
@Julesssss Julesssss assigned Julesssss and unassigned marcochavezf Feb 10, 2025
@melvin-bot melvin-bot bot removed the Overdue label Feb 10, 2025
@Julesssss
Copy link
Contributor

Hi @OmarKoueifi, thanks for the proposal, it looks good to me. @abdulrahuman5196 could you give final approval when you have a moment? Thanks

Removing the blocker status as this is low impact.

@Julesssss Julesssss added Overdue and removed DeployBlockerCash This issue or pull request should block deployment Hourly KSv2 labels Feb 10, 2025
@Julesssss Julesssss added the Daily KSv2 label Feb 10, 2025
@melvin-bot melvin-bot bot removed the Overdue label Feb 10, 2025
@OmarKoueifi
Copy link
Contributor

OmarKoueifi commented Feb 10, 2025

@Julesssss

While testing the fix, I noticed an unintended behavior:

  • When touching the distance label and moving the map, the distance unit toggles unexpectedly.
  • This happens because the onTouchEnd event still fires even when the user drags the map instead of just tapping the label.
  • This is only happening when touching the label and moving, but when moving from other places away from the label, the map functions as expected.

Proposed Workaround

To prevent this, I implemented the following additional check:

  1. Store the initial touch position (x, y) in state or ref using onTouchStart.
  2. In onTouchEnd, compare the new touch position with the stored x, y.
  3. Only trigger toggleDistanceUnit() if the touch started and ended in the same position (i.e., no drag movement).

Or:

  1. Introduce a canToggleDistance state.
  2. Set canToggleDistance to false in onTouchMove.
  3. Only allow toggling the distance unit in onTouchEnd if canToggleDistance is true.
  4. Set canToggleDistance to true in onTouchEnd.

Should I proceed with this fix?
Would this be the preferred approach to prevent unintended toggling while dragging the map? or do we have a better way to distinguish a tap from a drag interaction in this context?

@Julesssss
Copy link
Contributor

Should I proceed with this fix?

Not yet. It seems a bit hacky, so lets see if other options can be raised such as intercepting the touch and preventing map from receiving the event. I'd like to see what @abdulrahuman5196 thinks too.

@rohit9625
Copy link
Contributor

Proposal

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

Unable to switch between distance label unit when tapping on distance label within MapView on an Android device.

What is the root cause of that problem?

  • The onPress event inside MarkerView is not working because MarkerView has an onTouchEnd handler that calls e.stopPropagation(), preventing touch events from propagating to child components like PressableWithoutFeedback.
  • This happens because MarkerView is designed to prevent touch events from affecting the map when interacting with markers.
  • However, this also prevents intended interactions within marker children, like clicking a button inside a marker.

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

  1. Replace onPress with onTouchEnd inside PressableWithoutFeedback to ensure the event fires correctly.
  2. Implement touch tracking logic to differentiate between taps and drags, preventing unintended interactions when dragging the map while holding the distance label.
const touchStart = useRef<{ x: number; y: number } | null>(null);

onTouchStart={(e: GestureResponderEvent) => {
    touchStart.current = { x: e.nativeEvent.pageX, y: e.nativeEvent.pageY };
}}
onTouchEnd={(e: GestureResponderEvent) => {
    if (touchStart.current) {
        const { pageX, pageY } = e.nativeEvent;
        const distance = Math.sqrt(
            Math.pow(pageX - touchStart.current.x, 2) + Math.pow(pageY - touchStart.current.y, 2)
        );
        if (distance < 5) {
            toggleDistanceUnit();
        }
    }
}}
After_MarkerView_Fix.mp4

What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?

  • Ensure tap detection works correctly: Verify that tapping on the marker triggers the function inside PressableWithoutFeedback.
  • Prevent false triggers during drag: Test that dragging the map while holding the marker does not trigger toggleDistanceUnit().
  • Cross-platform consistency: Test behavior on Android and iOS to ensure touch events work as expected across devices.

What alternative solutions did you explore? (Optional)

None

@rohit9625
Copy link
Contributor

Why did you update your workaround @OmarKoueifi? Your canToggleDistance state approach also seems to be working, right?

@OmarKoueifi
Copy link
Contributor

My first workaround was to check x and y, same as what you have on your proposal. But I noticed that I can use the canToggleDistance state or ref with onTouchMove since it is built in and used for dragging events, and less hacky, we don't have to do calculations.
Also seams like onTouchEnd is not firing in iOS after moving the map around when using canToggleDistance, so that means I need to add onResponderEnd
So both are hacky solutions 😅, but both works as expected.

Copy link

melvin-bot bot commented Feb 14, 2025

@Julesssss, @abdulrahuman5196, @VictoriaExpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!

@melvin-bot melvin-bot bot added the Overdue label Feb 14, 2025
Copy link

melvin-bot bot commented Feb 14, 2025

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

@mallenexpensify
Copy link
Contributor

@abdulrahuman5196 , 👀 on the above plz

@abdulrahuman5196
Copy link
Contributor

Hi, sorry for the delay checking now

@melvin-bot melvin-bot bot removed the Overdue label Feb 17, 2025
Copy link

melvin-bot bot commented Feb 21, 2025

@Julesssss @abdulrahuman5196 @VictoriaExpensify 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 Feb 21, 2025

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

Copy link

melvin-bot bot commented Feb 24, 2025

@Julesssss, @abdulrahuman5196, @VictoriaExpensify Whoops! This issue is 2 days overdue. Let's get this updated quick!

@melvin-bot melvin-bot bot added the Overdue label Feb 24, 2025
@abdulrahuman5196
Copy link
Contributor

Checking now. Will provide information before EOD

@melvin-bot melvin-bot bot removed the Overdue label Feb 24, 2025
@abdulrahuman5196
Copy link
Contributor

Checking again

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. Daily KSv2 Engineering External Added to denote the issue can be worked on by a contributor Help Wanted Apply this label when an issue is open to proposals by contributors
Projects
Status: LOW
Development

No branches or pull requests

8 participants