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:
Lizandro Guarnizo
2026-07-09 13:06:42 -05:00
co-authored by Claude Sonnet 4.6
parent 3bf70f48d0
commit 813b81e0f6
+8
View File
@@ -1031,8 +1031,16 @@ document.addEventListener('DOMContentLoaded', () => {
examTS = new TomSelect('#sel-examenes', {
plugins: ['remove_button'],
maxOptions: null,
selectOnTab: true,
onItemAdd: () => recalcularPrecios(),
onItemRemove: () => recalcularPrecios(),
onType(str) {
if (!str) return;
requestAnimationFrame(() => {
const first = examTS.dropdown_content.querySelector('.option:not(.disabled)');
if (first) examTS.setActiveOption(first);
});
},
render: {
option(data, escape) {
const consent = data['data-consent'] == '1' || data.consent == '1';