Skip to content

Conversation

@chadbrokaw
Copy link
Collaborator

📝 Description

This pull request introduces a significant update to how location-based search results are retrieved and displayed, transitioning from a radius-based search to a dynamic bounding box approach that leverages the visible map area. It also improves the user experience with enhanced result headers and loading states, and refines code structure for better maintainability. The most important changes are grouped below:

Search Logic and Map Integration:

  • The search now uses a bounding box (representing the visible area of the map) for filtering results, rather than a fixed radius. When the user clicks "Search this area," the bounding box is calculated from the map's bounds and used for the search query; the radius-based filter is disabled in this case. (app/components/SearchAndBrowse/SearchMap/SearchMap.tsx, app/pages/SearchResultsPage/SearchResultsPage.tsx, app/utils/useAppContext.tsx) [1] [2] [3]
  • The search parameters are only configured and executed after the map has initialized and the bounding box is available, preventing premature queries and improving accuracy. (app/pages/SearchResultsPage/SearchResultsPage.tsx)

User Interface Enhancements:

  • The search results header now displays a range of results (e.g., "Showing 1-40 of 200 results") and includes the Clear Search button, improving clarity for users. This is implemented via a new SearchResultsHeader component and integrated across search and browse result pages. (app/components/ui/SearchResultsHeader.tsx, app/components/SearchAndBrowse/SearchResults/SearchResults.tsx, app/pages/BrowseResultsPage/BrowseResultsPage.tsx, app/pages/SearchResultsPage/SearchResultsPage.tsx) [1] [2] [3] [4]
  • A loading state is shown while the map is initializing and results are being fetched, improving feedback for users. (app/pages/SearchResultsPage/SearchResultsPage.module.scss, app/pages/SearchResultsPage/SearchResultsPage.tsx) [1] [2]

Styling Adjustments:

  • Font sizes and alignment for the search results header are adjusted for better readability and visual hierarchy. (app/components/SearchAndBrowse/SearchResults/SearchResults.module.scss) [1] [2]

Testing Improvements:

  • Tests for the search results page are updated to mock the map component and provide the necessary context for bounding box and radius logic, ensuring robust testing of the new search behavior. (app/pages/SearchResultsPage/SearchResultsPage.test.tsx) [1] [2]

Context and State Management:

  • The application context (useAppContext) is extended to handle the bounding box and its updater, and the default search radius is set to 1600 meters instead of "all". (app/utils/useAppContext.tsx, app/App.tsx, app/App.test.tsx) [1] [2] [3]

These changes collectively modernize the search experience, making it more intuitive and responsive to user interactions with the map.

@chadbrokaw chadbrokaw requested review from Copilot and removed request for Copilot September 2, 2025 17:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request transitions the search functionality from a radius-based approach to a dynamic bounding box system that uses the visible map area for location filtering. It also improves the user interface with enhanced result headers showing result ranges and better loading states.

  • Replaces fixed-radius search with dynamic bounding box calculated from the visible map area
  • Adds improved search results header showing "Showing X-Y of Z results" format with Clear Search button
  • Introduces loading states during map initialization to prevent premature queries

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
webpack.config.js Fixes typo in API_URL configuration and adjusts publicPath for development
app/utils/useAppContext.tsx Adds bounding box state management and changes default radius from "all" to 1600
app/pages/SearchResultsPage/SearchResultsPage.tsx Implements bounding box search logic with map initialization checks
app/components/ui/SearchResultsHeader.tsx Refactors to show result ranges and includes Clear Search button
app/components/SearchAndBrowse/SearchMap/SearchMap.tsx Adds bounding box calculation from map bounds on search actions
Various other files Updates to support new search paradigm with styling and test adjustments

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

{
context: ["/api-docs"],
target: config.API_UR || "http://localhost:3000",
target: config.API_URL || "http://localhost:3000",
Copy link

Copilot AI Sep 2, 2025

Choose a reason for hiding this comment

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

Fixed typo in variable name from API_UR to API_URL.

Copilot uses AI. Check for mistakes.
@chadbrokaw chadbrokaw merged commit 6577198 into main Sep 2, 2025
2 checks passed
@chadbrokaw chadbrokaw changed the title Development feat: Fix map Sep 2, 2025
Copy link

@rosschapman rosschapman left a comment

Choose a reason for hiding this comment

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

@chadbrokaw I took a look at this earlier because as I've expressed, I'm excited to watch this codebase develops. Awesome stuff!

Choose a reason for hiding this comment

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

praise: 😌 Really nice comments in handleSearchThisAreaClick() otherwise those operations are pretty opaque not behind meaningful names.

Comment on lines +97 to +100
case SearchMapActions.MapInitialized:
// Map has initialized and bounding box is now available
setIsMapInitialized(true);
return;

Choose a reason for hiding this comment

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

question: How do you find this little action dispatch mechanism? I was inspired by Redux-like stores. I had hoped it would be utilized further.

inSanFrancisco: false,
},
aroundUserLocationRadius: "all",
aroundUserLocationRadius: 1600,

Choose a reason for hiding this comment

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

suggestion (if-minor): What about putting this magic number in utils/location.tsx with DEFAULT_AROUND_PRECISION?

output: {
path: buildDir,
publicPath: "/dist/",
publicPath: process.env.NODE_ENV === "development" ? "/" : "/dist/",

Choose a reason for hiding this comment

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

question (if-minor): Why this change out of pure curiosity?

if (map) {
// Get the visible bounds of the map
const bounds = map.getBounds();
if (bounds) {

Choose a reason for hiding this comment

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

question (if-minor): Out of pure curiosity, did you find that bounds might be falsy sometimes?

// Set initial bounding box when map is first loaded
const idleListener = map.addListener("idle", () => {
// Remove the listener so it only fires once
google.maps.event.removeListener(idleListener);

Choose a reason for hiding this comment

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

thought: Man this kind of variable access in JS (via "hoisting") always breaks my brain. What about expanding this comment so folks unfamiliar with gmaps might understand this a little better:

Remove the listener so it only fires once on initialization because  the `idle` event will continue to fire when the map finishes panning, zooming, or loading.

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.

3 participants