mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-11-30 10:04:33 -06:00
Follow-up to #9058, answering your question there: yes, other TomSelects suffer the same fate. ### The underlying behaviour `clearOptions()` and `addOption()` only mark a tom-select drop-down's rendered content stale. Nothing repaints it. `open()` does not, and only the focus and input handlers call `refreshOptions()`. So a drop-down that is open, **or that is reopened without first losing focus**, keeps showing the previous option list. ### It had already been solved twice | Pane | Selector | Rebuilt from | Repaint before this PR | |---|---|---|---| | `gccdump-view` | pass list | compile result | yes | | `diff` | difftype | compile result | yes, as of #9058 | | `cfg-view` | function selector | `onCompileResult` | **no** | | `opt-pipeline` | group selector | `updateResults` | **no** | `gccdump-view` even carried a comment describing the exact mechanism. It just never made it to the other panes, so #9058 was the third independent rediscovery. This moves it into `static/tom-select-utils.ts` as `replaceOptions()` and routes all four sites through it, so the next pane that rebuilds a picker gets the repaint for free instead of finding out the hard way. ### This also corrects #9058 That PR guarded the refresh on `picker.isOpen`. **That was wrong.** A drop-down can be closed while the control still has focus, and reopening it in that state does not repaint, so the stale list survives. `gccdump-view` had it right by refreshing unconditionally, and the shared helper now does the same. ### Two subtleties worth checking in review - **`gccdump-view` keeps a trailing `refreshOptions()`.** Its `addItem()` after the rebuild goes through `refreshItems()`, which re-marks the content stale, so the repaint done inside `replaceOptions()` no longer covers that path. Verified in the tom-select source rather than assumed. - **`cfg-view` cleared its options before deciding whether it had a cfg at all.** Folding the clear into `replaceOptions()` would have left the previous functions listed when a compile yields no cfg (a blank input file, for instance), so the no-cfg path now empties the picker explicitly. ### Verification `ts-check`, biome and the frontend unit tests pass. As with #9058 the user-visible symptom is a race, so I can't demonstrate it deterministically; what I've checked is the mechanism in tom-select's own source, in particular that `refreshOptions(false)` gates both its open and close branches on that argument and so leaves the drop-down's state alone. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: mattgodbolt-molty <mattgodbolt-molty@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>