Skip to content

Conversation

@XinyuYangYXY
Copy link
Contributor

Fixes #6486

What changes did you make and why?

When switching away from Nearby and returning, the place-type chips remained visually selected but the map/list reset to unfiltered pins.
This PR ensures the selected place-type filters are persisted and restored within the same app session:

  • Persist selection on every change
    In NearbyFilterSearchRecyclerViewAdapter:

    • After toggling a chip, call NearbyFilterState.setSelectedLabels(new ArrayList<>(selectedLabels)) and then callback.filterByMarkerType(...).
    • After Clear (setRecyclerViewAdapterItemsGreyedOut) and Select all (setRecyclerViewAdapterAllSelected) operations, also update NearbyFilterState to keep state consistent.
  • Restore selection on Nearby init
    In NearbyParentFragment:

    • Introduce restoreStoredFilterSelection() and call it from initNearbyFilter() to re-apply saved labels to Label enum states and the adapter, then notifyDataSetChanged() so the UI, map, and list stay aligned with the saved filters.
    • Reset searchView state (de-iconify, clear query, remove focus) to avoid stale focus interfering with sheet/filters.

Scope: persistence is within the current app session.

Tests performed (required)

  • Build variant: debug-main (Commons app 6.0.2-debug-main~4ed9ad508)
  • Android device: Android 15 (API 35) emulator (Medium Phone)

Manual scenarios
1.Open the app and grant location permission.
2.Go to the Nearby tab.
3.Select one or more place-type chips (any types are fine).
4.Observe: the map updates and shows only the selected types.
5.Switch to another tab (e.g., Contributions / Explore).
6.Switch back to Nearby.
7.Observe: the chips are still selected, and now the map shows selected pins

Screenshots (for UI changes only)

Before:
e80fdc62bc5c5dd071823f9667daca58
94fff8ba7603f564916909641b04d493
e217070c89de1eedb71fb8f385cd9ed0

After repair:
cd8d74e3b99dae086306898db4f3d53c
d1de9e87f81ae36daeb1dcad74139a48
96c97ac9b15f175f3fb0a4469c7f0de7


@nicolas-raoul
Copy link
Member

Testing this now, it seems to be working great.
I will test a bit more tomorrow. :-)

@nicolas-raoul nicolas-raoul merged commit 7a865df into commons-app:main Oct 16, 2025
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.

[Bug]: Place-type stay selected after tab switch, but map resets to unfiltered pins

3 participants