Custom Select Module (customSelect.ts)
Module path: web_rviz/src/customSelect.ts
Purpose
Wraps native select elements with a styled, keyboard-accessible custom dropdown while keeping the native control as the source of truth.
Public API
CustomSelectController
refresh(): rebuilds the custom option list from the current nativeselectstate.dispose(): removes enhancement markup and restores the originalselectin place.
enhanceSelect(select: HTMLSelectElement): CustomSelectController
Enhances one select element and returns its controller.
refreshEnhancedSelect(select: HTMLSelectElement): void
Refreshes an already-enhanced select if a controller exists.
Behavior Notes
The target
selectmust already be attached to a parent element.Each
selectgets at most one controller; repeatedenhanceSelect()calls reuse the existing instance.A
MutationObserverwatches option and disabled-state changes so the custom menu stays in sync.Clicking outside the control or pressing
Escapecloses all open custom selects.Selecting a new option updates the native value and dispatches a bubbling
changeevent.