feat: Enter auto-selects first exam match in TomSelect
onType highlights the first visible option on each keystroke so pressing Enter immediately selects it — no need to arrow-down manually. Also adds selectOnTab for the same effect with Tab key. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
3bf70f48d0
commit
813b81e0f6
@@ -1031,8 +1031,16 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
examTS = new TomSelect('#sel-examenes', {
|
examTS = new TomSelect('#sel-examenes', {
|
||||||
plugins: ['remove_button'],
|
plugins: ['remove_button'],
|
||||||
maxOptions: null,
|
maxOptions: null,
|
||||||
|
selectOnTab: true,
|
||||||
onItemAdd: () => recalcularPrecios(),
|
onItemAdd: () => recalcularPrecios(),
|
||||||
onItemRemove: () => recalcularPrecios(),
|
onItemRemove: () => recalcularPrecios(),
|
||||||
|
onType(str) {
|
||||||
|
if (!str) return;
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
const first = examTS.dropdown_content.querySelector('.option:not(.disabled)');
|
||||||
|
if (first) examTS.setActiveOption(first);
|
||||||
|
});
|
||||||
|
},
|
||||||
render: {
|
render: {
|
||||||
option(data, escape) {
|
option(data, escape) {
|
||||||
const consent = data['data-consent'] == '1' || data.consent == '1';
|
const consent = data['data-consent'] == '1' || data.consent == '1';
|
||||||
|
|||||||
Reference in New Issue
Block a user