fix(form): close searchable single-select dropdown - #1381
Conversation
|
in dev mode of browser i tested some thing: ts.trigger = new Proxy(ts.trigger, { this will schow: so the dropdown will be closed now, but is directly after this opened again. Next test: ts.on('focus', function() { logged: So tomselect itself uses onfocus to reopen the dropdown. in your tomselect.js } |
|
may be you can add extra check in this if, to only do it if this is a searchable input field. |
|
have tested this new fix version with the docstatus field. DeV Console from browser: ts.trigger = new Proxy(ts.trigger, { Proxy(Function) {length: 1, name: 'trigger'} internaly dropdown gets closed but reopen dirct after that event. Extra scripting embedded in sqlpage with deferred loading solves the issue: tomselect does it right to close this dropbox with closeafterselect:true , but it gets focus again (or whatever) and reopens right after that, so user does not see its closed. |
|
@T-Doschke : i can't read your comment because of the formatting, but I can confirm I have tested the fix. |
have tested this new fix version with the docstatus field.
select
'docstatus' as name,
'Document Status' as label,
'select' as type,
1 as searchable,
2 as width,
'[{"label":"released","value":"50"},{"label":"created","value":"10"}]' as options;
DeV Console from browser:
var ts = document.querySelector('select[name="docstatus"]').tomselect;
ts.trigger = new Proxy(ts.trigger, {
apply(target, thisArg, args) {
console.log("EVENT:", args[0]);
return target.apply(thisArg, args);
}
});
Proxy(Function) {length: 1, name: 'trigger'}
VM105:5 EVENT: focus
VM105:5 EVENT: dropdown_open
VM105:5 EVENT: item_remove
VM105:5 EVENT: clear
VM105:5 EVENT: item_add
VM105:5 EVENT: dropdown_open
VM105:5 EVENT: change
VM105:5 EVENT: dropdown_close
VM105:5 EVENT: dropdown_close
VM105:5 EVENT: dropdown_open
internaly dropdown gets closed but reopen dirct after that event.
I am sorry but that does not solve the issue.
Extra scripting embedded in sqlpage with deferred loading solves the issue:
select 'html' as component,
'<script>
window.addEventListener("load", function() {
const sel = document.querySelector("select[name=docstatus]");
if (sel?.tomselect) {
sel.tomselect.on("item_add", function() {
console.log("item_add");
this.blur();
this.close();
});
}
});
</script>
' as html;
tomselect does it right to close this dropbox with closeafterselect:true , but it gets focus again (or whatever) and reopens right after that, so user does not see its closed. |
|
@T-Doschke : your comment looks AI-written. Just retried with the following sql file. select 'form' as component;
select
'docstatus' as name,
'Document Status' as label,
'select' as type,
1 as searchable,
2 as width,
'[{"label":"released","value":"50"},{"label":"created","value":"10"}]' as options;I confirm the issue you initially reported is now fixed. Selecting an option DOES close the dropdown. |
|
then i do not have the newest fix version and tested may be the "old" fix again. |

Summary
Fixes #1380.
Validation
CI Builds
Artifacts require GitHub repository read access and are retained according to the repository Actions retention policy.