Skip to content

Commit

Permalink
chore: optimize issue search (#7874)
Browse files Browse the repository at this point in the history
* chore: update advanced search

* chore: update
  • Loading branch information
ecmadao committed Aug 31, 2023
1 parent 5067abe commit fa1f747
Show file tree
Hide file tree
Showing 2 changed files with 234 additions and 166 deletions.
22 changes: 15 additions & 7 deletions frontend/src/components/AdvancedSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,18 @@ const query = computed(() => {
const getSearchParamsByText = (text: string): SearchParams => {
const plainQuery = query.value;
const scopeText = text.split(` ${plainQuery}`)[0] || "";
const scopeText = plainQuery ? text.split(plainQuery)[0] || "" : text;
return {
query: plainQuery,
scopes: scopeText.split(" ").map((scope) => {
return {
id: scope.split(":")[0] as SearchScopeId,
value: scope.split(":")[1],
};
}),
scopes: scopeText
.split(" ")
.map((scope) => {
return {
id: scope.split(":")[0] as SearchScopeId,
value: scope.split(":")[1],
};
})
.filter((scope) => scope.id && scope.value),
};
};
Expand All @@ -238,6 +241,11 @@ const onKeydown = (e: KeyboardEvent) => {
state.showSearchScopes = true;
return;
}
const params = getSearchParamsByText(state.searchText);
if (params.scopes.length === 0) {
state.showSearchScopes = true;
return;
}
const start = inputRef.value.inputElRef.selectionStart ?? -1;
const end = inputRef.value.inputElRef.selectionEnd ?? -1;
Expand Down

0 comments on commit fa1f747

Please sign in to comment.