Update the tagsinput.ts with the new 'autocomplete' event shape

This commit is contained in:
MareStare 2025-03-04 04:56:50 +00:00
parent 6b9b9d212f
commit 696a2fd74a
2 changed files with 3 additions and 5 deletions

View file

@ -1,6 +1,5 @@
import { $, $$, hideEl } from '../utils/dom';
import { assertNotNull } from '../utils/assert';
import { TermSuggestion } from '../utils/suggestions';
import { setupTagsInput, addTag, reloadTagsInput } from '../tagsinput';
const formData = `<form class="tags-form">
@ -96,7 +95,7 @@ describe('Fancy tags input', () => {
it('should respond to autocomplete events', () => {
setupTagsInput(tagBlock);
fancyText.dispatchEvent(new CustomEvent<TermSuggestion>('autocomplete', { detail: { value: 'a', label: 'a' } }));
fancyText.dispatchEvent(new CustomEvent<string>('autocomplete', { detail: 'a' }));
expect($$('span.tag', fancyInput)).toHaveLength(1);
});

View file

@ -4,7 +4,6 @@
import { assertNotNull, assertType } from './utils/assert';
import { $, $$, clearEl, removeEl, showEl, hideEl, escapeCss, escapeHtml } from './utils/dom';
import { TermSuggestion } from './utils/suggestions';
export function setupTagsInput(tagBlock: HTMLDivElement) {
const form = assertNotNull(tagBlock.closest('form'));
@ -48,8 +47,8 @@ export function setupTagsInput(tagBlock: HTMLDivElement) {
importTags();
}
function handleAutocomplete(event: CustomEvent<TermSuggestion>) {
insertTag(event.detail.value);
function handleAutocomplete(event: CustomEvent<string>) {
insertTag(event.detail);
inputField.focus();
}