## Summary
`RegionFilter.setSelected()` saved the selection and redrew the control
but never ran the `onChange` listeners; only a click (`toggleRegion`)
did. A programmatic selection therefore updated the dropdown while the
page kept showing data for the old selection until the next click.
Affected today: the Packets page applies a `?region=` URL parameter
through `setSelected`. It registers its listener afterwards, so its
first load is fine, but any other page's listener that is still
registered sees nothing. And anything that offers one-click region
groups has to wrap `setSelected` to make it re-query (an nginx-injected
overlay on one deployment does exactly that). This PR stands alone;
#2170 (configurable quick picks) does not need it.
`setSelected` now compares the new selection with the current one
(order-insensitive; empty and null both mean "all") and, only when they
differ, runs the listeners after saving and re-rendering, exactly as a
click does. Re-applying the current selection stays silent, so a caller
restoring state does not trigger a reload.
No existing issue covers this.
## Tests
- Red commit `75569b78`: `tests/unit/test-region-filter-setselected.js`
loads the real `public/region-filter.js` in a `vm` sandbox. Two cases
fail on `master` (a programmatic selection notifies once with the new
codes; a clear notifies once with `null`). Two pass on both commits on
purpose: re-applying the current selection in another order, and
clearing an empty selection, must not notify.
- Green commit `8a7ddfe1`: the fix.
- Listed in `test-all.sh` in sorted order; `test-test-inventory.js`
passes. `test-1108-region-hide-nodes.js` (the other region-filter suite)
passes. Frontend suites: 194 of 195; the one failure,
`test-issue-1956-release-routing.js`, needs CI's `GITHUB_REF_NAME` and
fails the same way on `master` locally.
## Review notes
- `packets.js` "clear all filters" calls `setSelected([])` and then
reloads itself. When a region was selected, that path now also triggers
the page's region listener, so the packets list is requested twice. It
is a cosmetic double fetch on an explicit user action; left as is to
keep this PR to the component.
- No performance claim; this is a correctness fix.
## SonarLint
SonarQube Community rules (the SonarLint engine) were run on the files
this PR touches, and only issues on lines it adds are listed.
- **Fixed** in `9e732706`: `node:` specifiers (S7772).
- **Kept on purpose:** S1523 on `vm.runInContext`, which loads the
repo's own `public/region-filter.js` as the other frontend unit tests
do.
## Checked against the repo rules
- Rebased onto `master` (`673442cc`). Each red commit was re-run and
still fails on its assertions; each green commit passes (TDD.md).
- `make test`: all 16 modules pass. Frontend suites: all pass except
`test-issue-1956-release-routing.js`, which needs CI's `GITHUB_REF_NAME`
and fails the same way on `master` locally (#2160 addresses it).
- No private data: test fixtures and examples use the codes the existing
tests use (SJC/SFO/LAX, `#be`-style scopes).
- No new `map[string]interface{}`, no hard-coded colours. `git add` was
explicit, and there is one logical change per commit.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01KaR4xu8gVykQBkH8yG8m6H
---------
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>