Skip to content

Commit b9bd212

Browse files
committed
fix autofocus on select fields with dropdown
fixes #297
1 parent 7297711 commit b9bd212

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# CHANGELOG.md
22

3-
## 0.20.5 (unreleased)
3+
## unreleased
44

55
- Fix missing visual indication of selected item in form dropdown fields.
66
- ![screenshot](https://github.com/tabler/tabler/assets/552629/a575db2f-e210-4984-a786-5727687ac037)
7-
7+
- fix autofocus on select fields with dropdown
88

99
## 0.20.4 (2024-04-23)
1010

sqlpage/tomselect.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
function sqlpage_select_dropdown() {
44
for (const s of document.querySelectorAll("[data-pre-init=select-dropdown]")) {
5-
new TomSelect(s, {
5+
// See: https://github.com/orchidjs/tom-select/issues/716
6+
// By default, TomSelect will not retain the focus if s is already focused
7+
// This is a workaround to fix that
8+
const is_focused = s === document.activeElement;
9+
const tom = new TomSelect(s, {
610
create: s.dataset.create_new
711
});
12+
if (is_focused) tom.focus();
813
}
914
}
1015

0 commit comments

Comments
 (0)