tom-select icon indicating copy to clipboard operation
tom-select copied to clipboard

[Bug]: text search field value is not cleared after an option is selected

Open lovasoa opened this issue 1 year ago • 5 comments

Bug description

When using the text search field in Tom Select.js, the entered search query remains in the input field after selecting an option. This requires the user to manually clear the existing text before searching for another option. No errors are logged in the console during this behavior.

Expected behavior

After selecting an option:

  • The text search field should automatically clear.
  • The user should be able to start typing a new search query without manual input clearing.

The correct behavior is observed everywhere on the official site https://tom-select.js.org/, but the person who wrote the example seems to have manually worked around the bug by adding the following to the options.

onItemAdd:function(){
  this.setTextboxValue('');
  this.refreshOptions();
}

In my opinion, the behavior exhibited on the official site is correct and should be the default.

Steps to reproduce

  1. Go to https://jsfiddle.net/rsj4hgd7/ image
  2. Start searching for an option. For instance, type "or" image
  3. Click the first proposition image
  4. After clicking, the search box displays a confusing message saying "No results found". Of course a result was found: I just clicked it! Now if I want to search for a new option, I have to manually delete the "or", then start typing the new option

Additional context

  • OS: all
  • Browser firefox
  • Version 2.4.1

Intially reported in https://github.com/sqlpage/SQLPage/discussions/704

lovasoa avatar Nov 22 '24 23:11 lovasoa

Maybe this should be a specific option as the default behavior might be useful when performing sequential and/or successive searches

adaniello avatar Jan 07 '25 12:01 adaniello

would like it to be optional as mentioned, as something you want to keep the search/filter active. Perhaps clicking outside the selection list (eg back in the main part of the select, or outside the control) could activate the clearing?

Offbeatmammal avatar Jan 14 '25 22:01 Offbeatmammal

I think it should be the default, like on the official website. It is unexpected to see "No results found" immediately after selecting a result.

lovasoa avatar Jan 15 '25 11:01 lovasoa

This issue has not been active in 120 days and has been marked "stale". Remove stale label or comment or this will be closed in 15 days

github-actions[bot] avatar May 16 '25 02:05 github-actions[bot]

still an issue

lovasoa avatar May 16 '25 08:05 lovasoa