From 696a2fd74a9a89a5f160a5897849e877d778a507 Mon Sep 17 00:00:00 2001 From: MareStare Date: Tue, 4 Mar 2025 04:56:50 +0000 Subject: [PATCH] Update the `tagsinput.ts` with the new `'autocomplete'` event shape --- assets/js/__tests__/tagsinput.spec.ts | 3 +-- assets/js/tagsinput.ts | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/assets/js/__tests__/tagsinput.spec.ts b/assets/js/__tests__/tagsinput.spec.ts index e32b2dfc..3c46eddc 100644 --- a/assets/js/__tests__/tagsinput.spec.ts +++ b/assets/js/__tests__/tagsinput.spec.ts @@ -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 = `
@@ -96,7 +95,7 @@ describe('Fancy tags input', () => { it('should respond to autocomplete events', () => { setupTagsInput(tagBlock); - fancyText.dispatchEvent(new CustomEvent('autocomplete', { detail: { value: 'a', label: 'a' } })); + fancyText.dispatchEvent(new CustomEvent('autocomplete', { detail: 'a' })); expect($$('span.tag', fancyInput)).toHaveLength(1); }); diff --git a/assets/js/tagsinput.ts b/assets/js/tagsinput.ts index 8a7d4b06..19396d80 100644 --- a/assets/js/tagsinput.ts +++ b/assets/js/tagsinput.ts @@ -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) { - insertTag(event.detail.value); + function handleAutocomplete(event: CustomEvent) { + insertTag(event.detail); inputField.focus(); }