fix(attestation): multiple tags improvements

- no menu when no matching tags
- insert a space after clicking a button
- allow no space before mention
This commit is contained in:
Colin Darie 2024-01-31 17:02:02 +01:00
parent 58064dc6cd
commit 6f49dd892d
No known key found for this signature in database
GPG key ID: 8C76CADD40253590
4 changed files with 19 additions and 4 deletions

View file

@ -88,6 +88,11 @@ class SuggestionMenu {
}
private render() {
if (this.#props.items.length == 0) {
this.#element?.remove();
return;
}
this.#element ??= this.createMenu();
const list = this.#element.firstChild as HTMLUListElement;
@ -161,6 +166,7 @@ export function createSuggestionMenu(
): Omit<SuggestionOptions<TagSchema>, 'editor'> {
return {
char: '@',
allowedPrefixes: null,
allowSpaces: true,
items: ({ query }) => {
return matchSorter(tags, query, { keys: ['label'] }).slice(0, 6);