Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: .sync() opens the dropdown, but .close() doesn't close it #869

Open
Offbeatmammal opened this issue Jan 21, 2025 · 1 comment
Open
Labels
bug Something isn't working

Comments

@Offbeatmammal
Copy link

Bug description

I'm activating TS as follows, against a simple multiple select.

 ts[id] = new TomSelect("#"+id,{dropdownParent:$("#"+id).parent(),plugins: {
		remove_button:{
			title:'Remove',
		}
	},onItemAdd:function(){
  this.setTextboxValue('');
  this.refreshOptions();
}})

later on, I change the underlying options (based on result of an ajax call) and do an

ts[id].sync()

this correctly updates the selected items, but opens the drop-down list.

ts[id].close()

doesn't close the list.

any suggestions on a workaround (I don't want the drop-down open unless the user explicitly clicks on the select)

Expected behavior

Expected behaviour would be for the dropdown list not to appear at all

Steps to reproduce

  1. Go to ...
  2. Click on ....
    ...
    X. See error

Additional context

  • OS: [e.g. iOS, Windows]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]
  • Device: [e.g. iPhone6]
@Offbeatmammal Offbeatmammal added the bug Something isn't working label Jan 21, 2025
@Offbeatmammal
Copy link
Author

found a workaround by delaying the .close() half a second

setTimeout(function(){ts[id].close();},500)

but that doesn't seem particularly elegant!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant