Clear a stale pin select when its value is unset#990
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a UI state-sync bug in the device config entry form where a reused <wa-select> (notably the pin picker) could keep displaying a stale GPIO after navigating through a dependency “detour” (e.g. sensor → add SPI bus → back), even though the form state had no value set.
Changes:
- Adjust
_syncSelectedAttrso it syncs to the selected option including the empty/unset case, clearing stale.valuewhen no option is selected. - Add inline rationale explaining why the empty case must be handled for pin selects that reuse the same DOM node.
| const selectedOption = select.querySelector<HTMLElement & { value: string }>( | ||
| "wa-option[selected]" | ||
| ); | ||
| const desired = selectedOption?.value ?? ""; | ||
| if (!desired) return; | ||
| const current = Array.isArray(select.value) |
|
|
esphbot
left a comment
There was a problem hiding this comment.
No blocking issues found.
|
Addressed both doc nits in 93ac4c8:
Copilot's regression-test suggestion is already covered by |
PR Review — Clear a stale pin select when its value is unsetCorrect, well-scoped bugfix with focused test coverage. Merge-ready. Strengths:
Verified independently that the change is safe for every other Checklist
Automated review by Kōan (Claude) |
esphbot
left a comment
There was a problem hiding this comment.
No blocking issues found.
What does this implement/fix?
Adding a bus device (e.g. an
atm90e32sensor), clicking "+ Add spi" to add the bus, then returning left the required CS Pin select showing a GPIO it never actually held; the Add button stayed greyed out because the value was never in form state. The same pin select DOM node is reused across the detour (sensor to spi to sensor), so the CS Pin kept displaying the SPI Clk Pin's GPIO that bled in from the detour.The pin select opts out of the generic value sync (
data-no-value-sync) and runs_syncSelectedAttr, which bailed when no option wasselected; that left the stale.valuein place. It now syncs to the selected option including the empty case, so a pin whose value is unset clears to empty. The unit picker (the otherdata-no-value-syncuser) always has a default unit selected, so it never hits the empty branch.Related issue or feature (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocsmaintenancecidependenciesFrontend coordination
Checklist
npm run lintpasses.npm run testpasses.