Skip to content

Move AOI's analyze and cancel card onto the core popup service - #456

Merged
slesaad merged 6 commits into
feature/298-map-popup-service-v3from
feature/299-aoi-popup-migration-v3
Sep 21, 2026
Merged

slesaad merged 6 commits into
feature/298-map-popup-service-v3from
feature/299-aoi-popup-migration-v3

Conversation

@CarsonDavis

@CarsonDavis CarsonDavis commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator
Category Lines added %
Tests 653 76%
Production code 203 24%

The AOI analyze/cancel card is no longer an overlay the plugin draws itself. It is the map library's own popup, requested from the core popup service.

Closes #299

Last of three PRs: engine placement (#454) → core popup service (#455) → this AOI migration. Stacked on #455. This is the PR where the change shows on screen.

The card is the map's own popup

Before, the card was a React component the tool rendered and closed itself: it did not track the ground, had no close control, and nothing clipped it. Now it comes from the popup service, so in the Demo Dashboard it sticks to the area through pan and zoom, carries the library's ×, and clips at the edge.

When the card appears, and how it waits for the camera

A search result, an Inspect click, a finished drawing and an upload all end the same way: the area is outlined, the map frames it if needed, and the card appears once above the selection. Already in view, it opens at the centroid; if the camera moves, the card waits for it to settle — 1.5 s safety net, pre-move view if framing fails — so it never flashes at the corner.

How it closes, and what happens to the selection

Analyze area hands the feature to analysis and leaves the outline up. Cancel, the ×, and a single click on the map close the card and clear the selection and outline; a click inside the panel does nothing. Click a second state in Inspect and you get its card. The card remembers which selection it belongs to, so a late close from the old card cannot clear the new selection.

Starting a drawing puts the card away

Starting a drawing retracts the card but keeps the previous selection outlined — otherwise it would sit there all session offering to analyze an area you are replacing. Back out before the first vertex and the card comes back. The first vertex drops the old outline. EXIT takes the card with it, including one still waiting on the camera.

Closing the results panel clears the outline

After Analyze, AOI hides its own panel and the Chart plugin's Analysis results panel takes its place. Before, closing that panel with its × left the outline on the map with no panel to clear it from; only exiting AOI itself removed it. AOI now listens to the framework's plugin-state announcements and clears the selection when the results panel goes from open to unloaded, and only on that transition, since the announcement fires for every plugin change in the app. Demo mission: draw a shape, Analyze, close the results panel; the outline goes with it. AOI's own panel stays hidden afterwards, as it did before.

What the plugin lost, and the generic title

AOITooltip.tsx and the .aoi-tooltip styles are deleted; no popup component or styling remains in the plugin. A selection with a blank name gets the title "Selected area": the service refuses a card with neither title nor body, which would strand the selection with no way to analyze or cancel.

Unchanged, and not here

Switching tools still clears the selection, Cancel still fires drawingCancelled, and requests still go through the global MMGIS API. The shape-picker and line/point bounds fixes are separate PRs.

Decisions to review

  • drawingCancelled fires only for the Cancel button. A dismiss (× or map click) clears the selection directly, so consumers hear only drawingCleared. The alternative is routing dismiss the same way, so abandoning an area is one event.
  • "Take my card down" is an unscoped map:hidePopup, issued at four points without knowing whether the card in core's single slot is AOI's. It replaces an id-scoped overlay removal; as written, any plugin can dismiss another's popup. Ownership is planned for a later PR.
  • The fallback title lives in the plugin, not the service. The realistic source is an unnamed uploaded area. The alternative is to let the request reject and treat the blank name as a data problem.

MMGIS resets the user agent's outline globally, and the card's buttons follow
the app rather than making an exception of themselves. The first action is
still focused when a card opens.
Replace the plugin's own overlay tooltip with map:showPopup / map:hidePopup,
so the card is placed by the map library, tracks the ground, and reports how
it closed on the request's own promise. Analyze hands the feature to the
analysis consumers; Cancel and a dismissal clear the selection; a card that
code took down leaves it alone.

Delete AOITooltip.tsx and its styling, hold the deferred show in a pending
token so moveend, the fallback timer and a rejected fit arbitrate to one
card, retract the current card at the start of a new selection, and suspend
and restore the card around a drawing session. Rename selectionTooltipAnchor
to selectionPopupAnchor.
Leaflet closes a popup on preclick, before the click reaches the engine's
feature-click listener, so on a second Inspect click the open card answers
dismiss before the new selection is applied and retracting it first cannot
un-settle it. Capture the selection a card is requested for and act on its
outcome only while that selection is still current.

Disarm a pending show in _clearSelection, before its guard, so no caller
leaves a ghost card to open up to 1.5s later. Fall back to a generic title
when a feature name is blank, which the service would otherwise reject,
stranding the selection with no way to analyze or cancel it. Report a failed
restore instead of leaving an unhandled rejection. Fold overlapping popup
tests together and trim comments.
Bring back the three checks the test merge dropped: destroy removes the
selection layer, leaves no current selection, and unhooks its subscriptions.
Assert that superseding a selection disarms the show it was waiting on.
Correct the retract-first comment, which claimed an answer arriving during
the camera flight could no longer reach the selection — that is the case the
capture-compare exists for.
The results panel takes AOI's slot after an analysis and unloads itself when
its header close is pressed, leaving the selection outlined on the map with
nothing left to act on it. Watch the lifecycle listing core already
broadcasts and clear the selection as the panel goes away.

Only the transition counts: plugins:changed reports the whole listing on
every lifecycle move, with the results panel unloaded through all of them, so
the state on its own is no reason to drop a selection.
@slesaad
slesaad force-pushed the feature/299-aoi-popup-migration-v3 branch from 8bc88d4 to 3bb30a9 Compare September 21, 2026 22:01
@slesaad
slesaad merged commit 44e679e into development Sep 21, 2026
4 checks passed
@CarsonDavis CarsonDavis linked an issue Sep 21, 2026 that may be closed by this pull request
4 tasks
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.

AOI's analyze/cancel card becomes the core popup

2 participants