Skip to content

Commit a4403eb

Browse files
committed
fix #719
1 parent 9e9d4e2 commit a4403eb

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
insert into t values (42); -- this next statement should not be executed
2121
```
2222
- Fix `error returned from database: 1295 (HY000): This command is not supported in the prepared statement protocol yet` when trying to use transactions with MySQL. `START TRANSACTION` now works as expected in MySQL.
23+
- Fix a bug where a multi-select dropdown would unexpectedly open when the form was reset.
2324

2425
## 0.31.0 (2024-11-24)
2526

sqlpage/tomselect.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,17 @@ function sqlpage_select_dropdown() {
1818
},
1919
});
2020
if (is_focused) tom.focus();
21-
s.form?.addEventListener("reset", () => setTimeout(tom.sync.bind(tom), 0));
21+
s.form?.addEventListener("reset", async () => {
22+
// The reset event is fired before the form is reset, so we need to wait for the next event loop
23+
await new Promise((resolve) => setTimeout(resolve, 0));
24+
// Sync the options with the new reset value
25+
tom.sync();
26+
// Wait for the options to be updated
27+
await new Promise((resolve) => setTimeout(resolve, 0));
28+
// "sync" also focuses the input, so we need to blur it to remove the focus
29+
tom.blur();
30+
tom.close();
31+
});
2232
}
2333
}
2434

0 commit comments

Comments
 (0)