food-oasis icon indicating copy to clipboard operation
food-oasis copied to clipboard

Serious Bug: Map - Mobile map doesn’t update when viewing an organization

Open fancyham opened this issue 11 months ago • 5 comments

Describe the bug

Serious bug:

When viewing a list of organizations, and tapping one to get details about it, the map does not update show or highlight the organization’s pin. Often the pin is way off-screen.

The map should re-center (ideally with a smooth scroll/pan) on the highlighted pin automatically, ideally showing both the user’s current location and the pin so that they can determine the relative location.

Steps to reproduce the issue

(if applicable, please specify platform (iOS, Android, Windows, Mac version) and brower)

  1. Go to foodoasis.net
  2. Enter a location to get a list of organizations
  3. Scroll around the map, zoom in, zoom out
  4. Tap an organization to view the organization detail page
  5. Map does not update to show the organization’s pin.

What's the expected result?

Map should re-center on the organization’s pin automatically, each time a new organization is viewed.

Ideally, the map smoothly pans to the new location, and ideally, the user’s current location / entered address is also visible on the map (though this may be difficult if the user has panned the map manually)

See Apple or Google maps or Yelp on mobile phones for example.

What's the actual result?

The organization’s pin may be highlighted, but is often off-screen with no indication for how to find the pin itself.

This is a regression — the previous version centered on highlighted pins properly.

Additional details / screenshot

  • Video recording (drag in)

Device configuration

  • Device: iPhone 13 mini
  • OS version: 17.4
  • Browser: Safari

fancyham avatar Mar 01 '24 21:03 fancyham

Hi @hanapotski , just checked out the devla site today and there's something weird happening:

When I tap on an org pin, the pin smooth-scrolls off the screen! Very smooth, but kinda weird :)

https://github.com/hackforla/food-oasis/assets/3376957/b0198e69-a47f-4c6e-a896-7d58698ad55b

fancyham avatar Apr 04 '24 01:04 fancyham

Thanks 🙏 This is a known bug. Qiqi's looking into it 👌

hanapotski avatar Apr 04 '24 04:04 hanapotski

Still working on this, but adding notes here for future me and future team:

  • I suspect related to
    • #2065
    • #2110
  • Issue seems to reproduce after adjusting map scale (aka zooming in/out). Locations are centered at first, but changing scale adds offsets to lat-long coordinates each time. Similar for clicking locations from side panel vs from map itself (Desktop)
  • Issue only shows up when side panel is open. (Desktop)

Jun-30-2024 10-29-35

danvgar avatar Jun 30 '24 17:06 danvgar

I believe issue is at L119 of ResultsMap.js and L96 of Desktop.js

Screenshot 2024-06-30 at 12 10 24 PM Screenshot 2024-06-30 at 12 10 09 PM

In Desktop.js, the width of the Mapbox viewport is always 100% of the device width. Opening or closing the List Panel does not affect this, as the List Panel is in the z-index above the Mapbox viewport. (See images above)

In ResultsMap.js, the center is offset by a constant lat/long value based on whether the List Panel is open. However, these constants are only accurate for the default zoom, and won't be entirely accurate if the zoom level is changed.

  const onClick = (e) => {
    mapRef.current?.flyTo({
      center: [
        isListPanelOpen && !isMobile ? e.lngLat.lng - 0.08 : e.lngLat.lng,
        isMobile ? e.lngLat.lat - 0.03 : e.lngLat.lat,
      ],
      duration: 2000,
    });
    // . . .
  };

Two potential solutions:

  1. Adjust the Desktop.js layout so that the mapbox width is adjusted when the List Panel is open, and remove the long/lat offsets.
  2. Change the offsets from a constant to a linear equation, so that the offsets adjust based on the zoom level. This would take some experimenting or research to figure out the exact equation. (e.g. lat = lat - 0.08 * zoom / 11)

danvgar avatar Jun 30 '24 19:06 danvgar

The same issue appears on mobile - and it’s trickier since the map viewport can change when the text panel resizes:

  • #2168

the above issue is very serious as it makes the mobile site very unusable

fancyham avatar Jul 08 '24 03:07 fancyham

closing this as this was fixed in this PR

hanapotski avatar Aug 06 '24 00:08 hanapotski

Hi folks -- thanks for tackling this!

I just QAed at devla.foodoasis.net -- could you check on these two issues? (I'm reopening this so it grabs your attention but let me know if there's something else we should do for QA stuff)

  • On screens 500-800px wide, the map pin isn't centered properly -- it's off to the right
  • On mobile screens, the pin still gets cut off? Seems like it's not recalculating the visible map size, but is expecting the text panel to be at 50% -- but that's not always the case and I think the org details appear at about ~75% of the screen, so map pin is obscured.

https://github.com/user-attachments/assets/ae209924-0230-495d-b812-af1126ae68ec

fancyham avatar Aug 06 '24 03:08 fancyham

Not sure if it's a normal behavior for a user to resize the window 🤔

hanapotski avatar Aug 06 '24 03:08 hanapotski

It doesn’t require resizing - that’s just to show the issues at different sizes, and the working one at desktop size. Try it out with browsers at those sizes - iPad portrait and a smartphone

fancyham avatar Aug 06 '24 04:08 fancyham

Hi Guys. I checked the devla.foodoasis.net site : this is what I am experiencing still: The icons are nonresponsive at times. And they are still NOT CENTERED in the selected location in the mobile version. Please see the clip attached:

https://github.com/user-attachments/assets/19cab516-3373-4a95-aaae-baaea8af4b04

Shienny1 avatar Aug 17 '24 20:08 Shienny1

This issue seems like a subset of

  • #2168

Please look at both — it’s likely the solution fixes both bugs.

This is high priority because the site is very unusable and buggy when the map goes off in unexpected directions! Hot-fix asap, please!

fancyham avatar Aug 17 '24 22:08 fancyham

Hi 👋 we are aware of the unresponsive icons bug, we have a ticket for it. Someone's already taking a look at it 👍

hanapotski avatar Aug 18 '24 01:08 hanapotski

Still working on this, but adding notes here for future me and future team:

Jun-30-2024 10-29-35 Jun-30-2024 10-29-35

just saw this. I think we should add a separate ticket for this as this needs more research/experimenting

hanapotski avatar Aug 18 '24 05:08 hanapotski

When making your PR. please assign @fancyham

ExperimentsInHonesty avatar Sep 06 '24 01:09 ExperimentsInHonesty