fix(filters): make sure spaces before and after are not removed

This commit is contained in:
kolaente 2024-03-05 18:56:47 +01:00
parent 981f2d0e70
commit 9ed93b181d
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 4 additions and 3 deletions

View File

@ -91,12 +91,13 @@ const highlightedFilterQuery = computed(() => {
let highlighted = escapeHtml(filterQuery.value)
dateFields
.forEach(o => {
const pattern = new RegExp(o + '\\s*(<|>|<=|>=|=|!=)\\s*([\'"]?)([^\'"\\s]+\\1?)?', 'ig');
highlighted = highlighted.replaceAll(pattern, (match, token, start, value, position) => {
const pattern = new RegExp(o + '(\\s*)(<|>|<=|>=|=|!=)(\\s*)([\'"]?)([^\'"\\s]+\\1?)?', 'ig');
highlighted = highlighted.replaceAll(pattern, (match, spacesBefore, token, spacesAfter, start, value, position) => {
if (typeof value === 'undefined') {
value = ''
}
return `${o} ${token} <button class="is-primary filter-query__date_value" data-position="${position}">${value}</button><span class="filter-query__date_value_placeholder">${value}</span>`
return `${o}${spacesBefore}${token}${spacesAfter}<button class="is-primary filter-query__date_value" data-position="${position}">${value}</button><span class="filter-query__date_value_placeholder">${value}</span>`
})
})
assigneeFields