Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: fix advanced search box jitters (#9365)

Liu Jia966ca75cec3
diff --git a/frontend/src/components/IssueV1/components/IssueSearch/AdvancedSearchBox.vue b/frontend/src/components/IssueV1/components/IssueSearch/AdvancedSearchBox.vue
index 8cdcd92592..23cfffeb92 100644
--- a/frontend/src/components/IssueV1/components/IssueSearch/AdvancedSearchBox.vue
+++ b/frontend/src/components/IssueV1/components/IssueSearch/AdvancedSearchBox.vue
@@ -102,7 +102,7 @@ import {
extractInstanceResourceName,
SearchParams,
SearchScopeId,
- isValidSearchScopeId,
+ buildSearchParamsBySearchText,
} from "@/utils";
const props = withDefaults(
@@ -330,7 +330,7 @@ const fullScopes = computed((): SearchScope[] => {
// filteredScopes will filter search options by chosen scope.
// For example, if users select a specific project, we should only allow them select instances related with this project.
const filteredScopes = computed((): SearchScope[] => {
- const params = getSearchParamsByText(state.searchText);
+ const params = buildSearchParamsBySearchText(state.searchText);
const existedScope = new Map<SearchScopeId, string>(
params.scopes.map((scope) => [scope.id, scope.value])
);
@@ -368,7 +368,7 @@ const filteredScopes = computed((): SearchScope[] => {
// searchScopes will hide chosen search scope.
// For example, if uses already select the instance, we should NOT show the instance scope in the dropdown.
const searchScopes = computed((): SearchScope[] => {
- const params = getSearchParamsByText(state.searchText);
+ const params = buildSearchParamsBySearchText(state.searchText);
const existedScope = new Set<SearchScopeId>(
params.scopes.map((scope) => scope.id)
);
@@ -405,7 +405,7 @@ const onOptionSelect = (scopeValue: string) => {
if (!scopeId) {
return;
}
- const params = getSearchParamsByText(state.searchText);
+ const params = buildSearchParamsBySearchText(state.searchText);
const index = params.scopes.findIndex((s) => s.id === scopeId);
if (index < 0) {
params.scopes.push({
@@ -436,7 +436,7 @@ const onClear = (immediate = false) => {
};
const debouncedUpdate = debounce(() => {
- emit("update:params", getSearchParamsByText(state.searchText));
+ emit("update:params", buildSearchParamsBySearchText(state.searchText));
}, 500);
const onUpdate = (value: string) => {
@@ -444,37 +444,6 @@ const onUpdate = (value: string) => {
debouncedUpdate();
};
-const query = computed(() => {
- const sections = state.searchText.split(" ");
- let i = 0;
- while (i < sections.length) {
- const section = sections[i];
- const keyword = section.split(":")[0];
- if (!isValidSearchScopeId(keyword)) {
- break;
- }
- i++;
- }
- return sections.slice(i).join(" ");
-});
-
-const getSearchParamsByText = (text: string): SearchParams => {
- const plainQuery = query.value.trim();
- 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],
- };
- })
- .filter((scope) => scope.id && scope.value),
- };
-};
-
onMounted(() => {
if (props.autofocus) {
inputRef.value?.inputElRef?.focus();