Skip to content

Commit 9f01ee2

Browse files
rameerezclaude
andcommitted
0.1.3: clear the model before announcing a make change
Switching make from Volkswagen to Suzuki reported {make: "suzuki", model: "golf"} — the old model against the new make. makeChanged() called notify() first and only cleared the dependent select after the fetch, so onChange consumers wrote a vehicle that does not exist straight into their form state. The model select is now emptied BEFORE the announcement, so the reported value is honest at every instant. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015jjKjr2ajZ4etdoMN6eC6k
1 parent 951c090 commit 9f01ee2

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

make-model-dropdown.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,18 @@
186186
}
187187

188188
async makeChanged() {
189+
// CLEAR THE MODEL BEFORE ANNOUNCING. The old model belongs to the old
190+
// make, so reporting {make: "suzuki", model: "golf"} for the moment
191+
// between the change and the fetch is not a lag, it is a wrong answer —
192+
// and onChange consumers write it straight into their form state.
193+
if (this.modelSelect) {
194+
fillSelect(this.modelSelect, this.config.placeholderModel, [], this.config, "")
195+
}
189196
this.notify()
190197
if (!this.modelSelect) return
191198

192199
const makeValue = this.makeSelect.value
193200
if (!makeValue || makeValue === "other") {
194-
fillSelect(this.modelSelect, this.config.placeholderModel, [], this.config, "")
195201
if (makeValue === "other" && this.config.includeOther) appendOther(this.modelSelect)
196202
return
197203
}
@@ -427,6 +433,6 @@
427433

428434
return {
429435
attach(options) { return new Instance(options) },
430-
version: "0.1.2"
436+
version: "0.1.3"
431437
}
432438
})

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "make-model-dropdown",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "Car make and model dropdown for any web page. A dependent make/model picker with live vehicle data from the VehiclesDB API: 14,000+ models, 850+ makes, cars and motorcycles to trucks and buses, from official registers of 14 countries. Zero dependencies.",
55
"keywords": [
66
"car make model dropdown",

0 commit comments

Comments
 (0)