Skip to content

fix: handle zero saved coordinates - #67

Closed
tharunreddy08 wants to merge 1 commit into
Janani-bn:mainfrom
tharunreddy08:fix/41-saved-location-zero-coordinates
Closed

tharunreddy08 wants to merge 1 commit into
Janani-bn:mainfrom
tharunreddy08:fix/41-saved-location-zero-coordinates

Conversation

@tharunreddy08

Copy link
Copy Markdown

Summary

Fixes #41 — Saved location is ignored when latitude or longitude is 0.

Changes

  • Added coordinate validation that does not treat 0 as a missing value.
  • Updated the saved-location availability check.
  • Updated the saved-location handler to use the same validation logic.
  • Ensures valid coordinates such as 0, 0 are accepted.

Testing

  • Verified the saved-location logic with zero latitude/longitude values.
  • Verified that missing coordinate values are still rejected.

Closes #41

Copilot AI lite review requested due to automatic review settings September 27, 2026 05:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Non-numeric and non-finite coordinates are still accepted.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Fixes saved-location handling so valid coordinates of 0 are accepted.

Changes:

  • Updates coordinate validation.
  • Applies validation to saved-location visibility and handling.
  • Still requires rejection of non-numeric coordinate values.
File Description
src/​components/​NearbyComplaints.jsx Updates saved-coordinate validation and usage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

}
};

const hasCoordinate = (value) => value !== null && value !== undefined && value !== '';
@Janani-bn

Copy link
Copy Markdown
Owner

@tharunreddy08 This fixes 0 coordinates, but #41 also requires non-numeric coordinates to be rejected. hasCoordinate only checks for null/undefined/empty string, so values like NaN, Infinity, or not-a-number still show the saved-location button and get passed to the nearby request. Please reject blank values and use Number.isFinite(Number(value)) for both latitude and longitude, while keeping 0 valid. Apply the same check to the button and click handler.

@Janani-bn

Copy link
Copy Markdown
Owner

This accepts 0 coordinates, but hasCoordinate still accepts NaN, Infinity, and non-numeric text. Please reject invalid or blank values in both the saved-location button check and the click handler, while keeping 0 valid. This overlaps with #80's updated coordinate fix, so please reconcile the two branches.

@Janani-bn

Copy link
Copy Markdown
Owner

@tharunreddy08 The coordinate check still lets non-numeric values such as NaN and Infinity through, so #41 and the earlier review aren't fully addressed. Please validate finite numeric values in both the button and click handler while keeping 0 valid. #87 now covers this same fix, so please reconcile or close the duplicate PR.

@Janani-bn

Copy link
Copy Markdown
Owner

@tharunreddy08 Thanks for this. The same change already landed in #87, so this one is now obsolete. Closing it. Appreciate the contribution!

@Janani-bn Janani-bn closed this Oct 15, 2026
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.

Saved location is ignored when latitude or longitude is 0

3 participants