Skip to content

form with single select dropdown field, with searchable on, remains open after choosing an entry #1380

Description

@T-Doschke

Introduction

form with single select dropdown field remains open after choosing an entry

To Reproduce

select 'form' as component,
'import' as validate;

select
 'docstatus' as name,
 'select' as type,
 2 as width,
 '[{"label":"released","value":"50"},{"label":"created","value":"10"}]' as options;

Actual behavior

After following these steps, what happened ?
UX click on dropdown, select an entry, dropdown remains visible.

Screenshots

If applicable, add screenshots to help explain your problem.

Expected behavior

after choosing an entry, dropdown should close.

Version information

  • OS: windows
  • MSSQL
  • SQLPage Version 0.45.0

Additional context

your tomselect.js
has on line 33 following;

    onItemAdd: function () {
      this.setTextboxValue("");
      this.refreshOptions();
    },
    ...
this need extension 

onItemAdd: function () {
    this.setTextboxValue("");
    this.refreshOptions();
 
    if (this.settings.mode === "single") {
      this.blur();
      this.close();
    }
},
...
or without this.bur() line.

workaround so far:

select 'html' as component,
'<script>
window.addEventListener("load", function() {
    const sel = document.querySelector("select[name=reminder_to]");

    console.log("Select gefunden:", !!sel);
    console.log("TomSelect vorhanden:", !!sel?.tomselect);

    if (sel?.tomselect) {

        sel.tomselect.on("item_add", function() {
            console.log("item_add");
            this.blur();
            this.close();
        });

        console.log("Hook registriert");
    }
});
</script>
' as html;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions