mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-03-17 17:10:03 +01:00
Update the tagsinput.ts
with the new 'autocomplete'
event shape
This commit is contained in:
parent
6b9b9d212f
commit
696a2fd74a
2 changed files with 3 additions and 5 deletions
|
@ -1,6 +1,5 @@
|
||||||
import { $, $$, hideEl } from '../utils/dom';
|
import { $, $$, hideEl } from '../utils/dom';
|
||||||
import { assertNotNull } from '../utils/assert';
|
import { assertNotNull } from '../utils/assert';
|
||||||
import { TermSuggestion } from '../utils/suggestions';
|
|
||||||
import { setupTagsInput, addTag, reloadTagsInput } from '../tagsinput';
|
import { setupTagsInput, addTag, reloadTagsInput } from '../tagsinput';
|
||||||
|
|
||||||
const formData = `<form class="tags-form">
|
const formData = `<form class="tags-form">
|
||||||
|
@ -96,7 +95,7 @@ describe('Fancy tags input', () => {
|
||||||
|
|
||||||
it('should respond to autocomplete events', () => {
|
it('should respond to autocomplete events', () => {
|
||||||
setupTagsInput(tagBlock);
|
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);
|
expect($$('span.tag', fancyInput)).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
import { assertNotNull, assertType } from './utils/assert';
|
import { assertNotNull, assertType } from './utils/assert';
|
||||||
import { $, $$, clearEl, removeEl, showEl, hideEl, escapeCss, escapeHtml } from './utils/dom';
|
import { $, $$, clearEl, removeEl, showEl, hideEl, escapeCss, escapeHtml } from './utils/dom';
|
||||||
import { TermSuggestion } from './utils/suggestions';
|
|
||||||
|
|
||||||
export function setupTagsInput(tagBlock: HTMLDivElement) {
|
export function setupTagsInput(tagBlock: HTMLDivElement) {
|
||||||
const form = assertNotNull(tagBlock.closest('form'));
|
const form = assertNotNull(tagBlock.closest('form'));
|
||||||
|
@ -48,8 +47,8 @@ export function setupTagsInput(tagBlock: HTMLDivElement) {
|
||||||
importTags();
|
importTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAutocomplete(event: CustomEvent<TermSuggestion>) {
|
function handleAutocomplete(event: CustomEvent<string>) {
|
||||||
insertTag(event.detail.value);
|
insertTag(event.detail);
|
||||||
inputField.focus();
|
inputField.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue