Skip to content

[MOL-21191][WEIDONG] add restrictNonSGLocation to block out-of-Singapore selections using SLA National Map Polygon boundary - #676

Open
weidong-gws wants to merge 5 commits into
mainfrom
MOL-21191
Open

[MOL-21191][WEIDONG] add restrictNonSGLocation to block out-of-Singapore selections using SLA National Map Polygon boundary#676
weidong-gws wants to merge 5 commits into
mainfrom
MOL-21191

Conversation

@weidong-gws

@weidong-gws weidong-gws commented Jul 22, 2026

Copy link
Copy Markdown

add restrictNonSGLocation to block out-of-Singapore selections using SLA National Map Polygon boundary

Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing apis or functionality to change)
  • Documentation (change to documentation, comments or API descriptions)
  • Tests (improvements to unit tests or E2E tests)
  • Other (technical improvements, refactoring, or changes that don't fall into the above categories)

Description of changes

Classification: a coordinate is judged in/out of Singapore against the coastal outlines of SLA's National Map Polygon dataset (data.gov.sg), embedded as singapore-boundary.data.ts and produced by scripts/generate-singapore-boundary.js (point-in-polygon + a 10 km near-shore water tolerance). A JOHOR (MALAYSIA) building name short-circuits to "outside". Areas inside Singapore with no nearby address (sea off Changi, reservoirs) remain selectable.

Three enforcement layers, one shared predicate (LocationHelper.checkIsLocationOutsideSG): (1) on Confirm, an out-of-SG selection shows the "This location is outside Singapore." prompt with an Edit location button (map stays open) instead of confirming, and fires the error event with errorType: "NonSGLocationError"; (2) out-of-SG prefill values are cleared; (3) a yup submit rule blocks such values.

Non-breaking & opt-in (behaviour unchanged when the prop is absent). Custom copy via validation: [{ nonSGLocation: true, errorMessage: "…" }].

Checklist

  • Changes follow the project guidelines in CONTRIBUTING.md
  • Looks good on mobile and tablet
  • Updated documentation
  • Added/updated unit tests

Screenshots

image

…ore selections using SLA National Map Polygon boundary
@weidong-gws weidong-gws changed the title [MOL-21191][WEIDONG] add restrictNonSGLocation to block out-of-Singap… [MOL-21191][WEIDONG] add restrictNonSGLocation to block out-of-Singapore selections using SLA National Map Polygon boundary Jul 22, 2026
Comment thread src/components/fields/location-field/location-modal/location-modal.tsx Outdated
Comment thread src/components/fields/location-field/location-modal/location-modal.tsx Outdated
Comment thread src/components/fields/location-field/location-helper.ts Outdated
weidong-gws and others added 2 commits August 4, 2026 15:59
…trigger, treat 0 as valid coordinate, fix stale restrictNonSGLocation on runtime toggle
Resolve conflict in location-field.spec.tsx: keep restrictNonSGLocation test suite
alongside upstream's dirtyStateTestSuite refactor.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

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.

Suggested change
}, [isRecaptchaReady, validSGLocation]);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@weili-govtech thanks for your review, i just pushed another commit to add restrictNonSGLocation and mustHavePostalCode to prefill effect deps. Please help review again, thanks.

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.

5 participants