onLegendSelect says when it did not select
A SILENT `return` ON A PRECONDITION IS INDISTINGUISHABLE AT THE RENDERED LAYER
FROM THE REQUEST NEVER ARRIVING. The "Show on map" interop bug had three layers
stacked under one symptom: an element event with no replay, an id resolved
against legendNodes that had not loaded, and this function no-op'ing on a missing
'tapestry-fill' layer. Each fix looked sufficient because all three produced the
same nothing. regions-plugin fixed the first two by retaining the request and
flagged the third as mine, since it has three call sites — correctly, and this is
it.
IT NOW RETURNS A BOOLEAN. true when the selection was applied, false when it
bailed on the readiness check.
THE EARLY RETURN STAYS, AND STAYS FREE OF SIDE EFFECTS. It is a documented
readiness gate — the comment at :630 calls it "THE REAL READINESS SIGNAL" — and
other code relies on it bailing rather than throwing or queueing. A boolean is
the smallest change that makes the bail OBSERVABLE without altering when it
happens.
TWO EXITS RETURN true THAT MIGHT LOOK LIKE FAILURES, and the distinction is
load-bearing rather than cosmetic:
- batch mode fed the selection UNION instead of isolating. That is the correct
behaviour there, not a failure to isolate. A caller retrying because it read
`false` would toggle the zone back OUT of the union.
- the un-isolate (node == null) IS the action, and it succeeded.
And the success path returns true EXPLICITLY: an implicit fall-through yields
undefined, which is falsy, so a caller checking the result would read success as
failure and retry — the opposite of what this value is for.
No caller reads the value yet, so the change is purely additive and cannot
regress: verified all four call sites (:945 un-isolate, :1539 paintAll's
re-apply, :1638 and :1641 in the select-zone path) ignore it today. regions'
applySelectZone is where it becomes useful — it already retains on no-effect by
checking whether selectedKey held, and can now ask the applier directly instead
of inferring.
BUNDLE=my-upg-100-list vite build clean.
This commit is contained in:
parent
462d12e3b0
commit
14d6f4dfba
1 changed files with 26 additions and 3 deletions
|
|
@ -1461,14 +1461,33 @@ function packetLang() {
|
|||
return (typeof l === 'string' && l) || 'en';
|
||||
}
|
||||
|
||||
// ★ IT REPORTS WHETHER IT ACTED. Returns true when the selection was applied, false when it bailed.
|
||||
//
|
||||
// WHY: a silent `return` on a precondition is INDISTINGUISHABLE AT THE RENDERED LAYER from the
|
||||
// request never arriving (regions-plugin + upg100, 2026-09-26). The "Show on map" interop bug had
|
||||
// three layers stacked under one symptom — an element event with no replay, an id resolved against
|
||||
// unloaded legendNodes, and THIS function no-op'ing on a missing layer — and each fix looked
|
||||
// sufficient because all three produced the same nothing. Two were fixed by retaining the request;
|
||||
// this one is the third, and it will grow a fourth layer for whoever comes next unless the applier
|
||||
// says when it did not apply.
|
||||
//
|
||||
// ⚠ THE EARLY RETURN STAYS, and it stays SILENT of side effects — it is a documented readiness gate
|
||||
// (see the comment at :630, "THE REAL READINESS SIGNAL"), and other code relies on it bailing rather
|
||||
// than throwing or queueing. Returning a boolean is the smallest change that makes the bail
|
||||
// OBSERVABLE without changing when it happens: a caller that cares can retain and retry, and the two
|
||||
// callers that do not (paintAll's re-apply, the un-isolate at :945) are unaffected by a value they
|
||||
// ignore.
|
||||
function onLegendSelect(node) {
|
||||
if (!map || !map.getLayer('tapestry-fill')) return
|
||||
if (!map || !map.getLayer('tapestry-fill')) return false
|
||||
// R1.2 D-6: in batch mode the legend feeds the selection union, NOT the isolate.
|
||||
// (node is non-null on a row tap; the legend emits null when a row is re-tapped
|
||||
// to deselect — in batch mode that null is a no-op, the union persists.)
|
||||
if (batchMode.value) {
|
||||
if (node) toggleZoneSelection(node)
|
||||
return
|
||||
// TRUE: batch mode HANDLED the request — it fed the union, which is the correct behaviour here
|
||||
// rather than a failure to isolate. A caller retrying because it read `false` would toggle the
|
||||
// zone back OUT of the union, so this distinction is load-bearing, not cosmetic.
|
||||
return true
|
||||
}
|
||||
if (!node) {
|
||||
// restore the full 26-zone tapestry
|
||||
|
|
@ -1478,7 +1497,7 @@ function onLegendSelect(node) {
|
|||
map.setFilter('tapestry-line', null)
|
||||
// restore FULL opacity to match the new visible-dots baseline (BUG-UPG100-DOTS 2026-09-19)
|
||||
map.setPaintProperty('upg-pins', 'circle-opacity', 1)
|
||||
return
|
||||
return true // the un-isolate IS the action; it succeeded
|
||||
}
|
||||
_isolatedNode = node
|
||||
const keys = [...descendantKeys(node)]
|
||||
|
|
@ -1493,6 +1512,10 @@ function onLegendSelect(node) {
|
|||
}
|
||||
const b = boundsFor((f) => keys.includes(f.properties.zoneKey))
|
||||
if (b) map.fitBounds(b, { padding: 40, duration: 700, maxZoom: 6 })
|
||||
// EXPLICIT, not an implicit undefined: the isolate was applied. An implicit fall-through returns
|
||||
// undefined, which is falsy, so a caller checking the result would read the SUCCESS path as a
|
||||
// failure and retry — the opposite of the bug this return value exists to expose.
|
||||
return true
|
||||
}
|
||||
|
||||
// ── ONE paint entrypoint (P0 4188af3d / LESSON-03 L7+L10) ────────────────────
|
||||
|
|
|
|||
Loading…
Reference in a new issue