Bug description
I'm trying to integrate tom-select.js into a WordPress plugin and am running into the following.
I'm initializing it on a select element. After adding items, I found it is possible to click the items, after which isInputHidden becomes true, and the input element hides for some reason. The hiding is via a class .input-hidden. I can easily unhide it by overriding the CSS, but after that, it does not receive keyboard input.
If found the cause here:
|
// don't enter text in the control_input when active items are selected |
|
if( self.isInputHidden && !isKeyDown(constants.KEY_SHORTCUT,e) ){ |
|
preventDefault(e); |
|
} |
I'm not sure what the logic is of deactivating keyboard input and hiding the input.
What I'd ideally want is:
- that nothing happens when clicking items, there is no use for it in my case: they are already selected.
- that the input stays visible
- most importantly: that the input is not disabled for keyboard input.
In the docs, I see no way to disable clickability (+ all logic running after that), or any way to keep the input from hiding and being functional.
After some experimenting, I found this works to counteract the logic and fix the keyboard input. Not ideal but at least it works:
onItemSelect: function(e,item) {
let self = this;
setTimeout(function() {
self.clearActiveItems();
self.focus();
}, 0);
},
I'm not sure if I am missing something, if this is a bug report, or a feature request.
Expected behavior
Preferably: that there would be an option that makes sure that nothing happens when clicking items:
- no class,
- no hidden input
- no disabling of keyboard input.
3 is the main problem, 1 and 2 can be counteracted with CSS. But a way to prevent the hiding too would also be logical. And just nothing happening would be ideal.
Steps to reproduce
- add some CSS to make the input visible even if hidden:
.input-hidden .ts-control > input {
left: 0;
opacity: 1;
position: static;
}
- Click items in the dropdown
- Click any selected item in the control
- Try to use the keyboard to input text
- See that keyboard input is blocked, despite a blinking cursor.
Additional context
Bug description
I'm trying to integrate tom-select.js into a WordPress plugin and am running into the following.
I'm initializing it on a select element. After adding items, I found it is possible to click the items, after which
isInputHiddenbecomes true, and the input element hides for some reason. The hiding is via a class.input-hidden. I can easily unhide it by overriding the CSS, but after that, it does not receive keyboard input.If found the cause here:
tom-select/src/tom-select.ts
Lines 757 to 760 in 4522c18
I'm not sure what the logic is of deactivating keyboard input and hiding the input.
What I'd ideally want is:
In the docs, I see no way to disable clickability (+ all logic running after that), or any way to keep the input from hiding and being functional.
After some experimenting, I found this works to counteract the logic and fix the keyboard input. Not ideal but at least it works:
I'm not sure if I am missing something, if this is a bug report, or a feature request.
Expected behavior
Preferably: that there would be an option that makes sure that nothing happens when clicking items:
3 is the main problem, 1 and 2 can be counteracted with CSS. But a way to prevent the hiding too would also be logical. And just nothing happening would be ideal.
Steps to reproduce
Additional context