don't backfill tags, close dropdown on tab
This commit is contained in:
@@ -4,10 +4,6 @@ import {RootStoreModel} from '../root-store'
|
|||||||
import Fuse from 'fuse.js'
|
import Fuse from 'fuse.js'
|
||||||
import {isObj, hasProp, isStrArray} from 'lib/type-guards'
|
import {isObj, hasProp, isStrArray} from 'lib/type-guards'
|
||||||
|
|
||||||
function uniq(arr: string[]) {
|
|
||||||
return Array.from(new Set(arr))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used only to persist recent tags across app restarts.
|
* Used only to persist recent tags across app restarts.
|
||||||
*
|
*
|
||||||
@@ -100,7 +96,7 @@ export class TagsAutocompleteModel {
|
|||||||
// search amongst mixed set of tags
|
// search amongst mixed set of tags
|
||||||
const results = fuse.search(this.query).map(r => r.item)
|
const results = fuse.search(this.query).map(r => r.item)
|
||||||
// backfill again in case search has no results
|
// backfill again in case search has no results
|
||||||
return uniq([...results, ...items]).slice(0, 9)
|
return results.slice(0, 9)
|
||||||
}
|
}
|
||||||
|
|
||||||
async search(query: string) {
|
async search(query: string) {
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ export function TagInput({
|
|||||||
|
|
||||||
if (key === 'Backspace' && value === '') {
|
if (key === 'Backspace' && value === '') {
|
||||||
addTags(tags.slice(0, -1))
|
addTags(tags.slice(0, -1))
|
||||||
|
closeDropdownAndReset()
|
||||||
} else if (key === ' ') {
|
} else if (key === ' ') {
|
||||||
e.preventDefault() // prevents an additional space on web
|
e.preventDefault() // prevents an additional space on web
|
||||||
addTagAndReset(value)
|
addTagAndReset(value)
|
||||||
|
|||||||
Reference in New Issue
Block a user