1
0

fix(filters): do not fire filter change immediately

Related to https://kolaente.dev/vikunja/vikunja/issues/2194#issuecomment-61081
This commit is contained in:
kolaente 2024-03-13 19:58:24 +01:00
parent 8c826c44d2
commit d4605905d3
No known key found for this signature in database
GPG Key ID: F40E70337AB24C9B
2 changed files with 18 additions and 5 deletions

View File

@ -20,6 +20,7 @@ import {
getFilterFieldRegexPattern, getFilterFieldRegexPattern,
LABEL_FIELDS, LABEL_FIELDS,
} from '@/helpers/filters' } from '@/helpers/filters'
import {useDebounceFn} from '@vueuse/core'
const { const {
modelValue, modelValue,
@ -236,6 +237,10 @@ function autocompleteSelect(value) {
autocompleteResults.value = [] autocompleteResults.value = []
} }
// The blur from the textarea might happen before the replacement after autocomplete select was done.
// That caused listeners to try and replace values earlier, resulting in broken queries.
const blurDebounced = useDebounceFn(() => emit('blur'), 500)
</script> </script>
<template> <template>
@ -264,7 +269,7 @@ function autocompleteSelect(value) {
@input="handleFieldInput" @input="handleFieldInput"
@focus="onFocusField" @focus="onFocusField"
@keydown="onKeydown" @keydown="onKeydown"
@blur="e => emit('blur', e)" @blur="blurDebounced"
/> />
<div <div
class="filter-input-highlight" class="filter-input-highlight"

View File

@ -110,7 +110,15 @@ function change() {
const filter = transformFilterStringForApi( const filter = transformFilterStringForApi(
params.value.filter, params.value.filter,
labelTitle => labelStore.filterLabelsByQuery([], labelTitle)[0]?.id || null, labelTitle => labelStore.filterLabelsByQuery([], labelTitle)[0]?.id || null,
projectTitle => projectStore.searchProject(projectTitle)[0]?.id || null, projectTitle => {
const found = projectStore.findProjectByExactname(projectTitle)
if (found === null) {
return null
}
return found[0]?.id || null
},
) )
let s = '' let s = ''