Fix project dependencies search (#4932)

* add search on all project types except mod packs

* add search by ID

* fix placeholder

* rename to dependency select
This commit is contained in:
Truman Gao
2025-12-19 12:27:17 -08:00
committed by GitHub
parent 0268600044
commit 1f48f5b5af
3 changed files with 21 additions and 5 deletions

View File

@@ -4,9 +4,10 @@
placeholder="Select project"
:options="options"
:searchable="true"
search-placeholder="Search by name, slug, or paste ID..."
search-placeholder="Search by name or paste ID..."
:no-options-message="searchLoading ? 'Loading...' : 'No results found'"
@search-input="(query) => handleSearch(query)"
:disableSearchFilter="true"
/>
</template>
@@ -34,10 +35,24 @@ const search = async (query: string) => {
const results = await labrinth.projects_v2.search({
query: query,
limit: 20,
facets: [['project_type:mod']],
facets: [
[
'project_type:mod',
'project_type:plugin',
'project_type:shader ',
'project_type:resourcepack',
'project_type:datapack',
],
],
})
options.value = results.hits.map((hit) => ({
const resultsByProjectId = await labrinth.projects_v2.search({
query: '',
limit: 20,
facets: [[`project_id:${query}`]],
})
options.value = [...resultsByProjectId.hits, ...results.hits].map((hit) => ({
label: hit.title,
value: hit.project_id,
icon: defineAsyncComponent(() =>

View File

@@ -92,7 +92,7 @@ import {
} from '@modrinth/ui'
import type { DropdownOption } from '@modrinth/ui/src/components/base/Combobox.vue'
import ModSelect from '~/components/ui/create-project-version/components/ModSelect.vue'
import ModSelect from '~/components/ui/create-project-version/components/DependencySelect.vue'
import { injectManageVersionContext } from '~/providers/version/manage-version-modal'
import AddedDependencyRow from '../components/AddedDependencyRow.vue'

View File

@@ -170,6 +170,7 @@ const props = withDefaults(
triggerClass?: string
forceDirection?: 'up' | 'down'
noOptionsMessage?: string
disableSearchFilter?: boolean
}>(),
{
placeholder: 'Select an option',
@@ -244,7 +245,7 @@ const optionsWithKeys = computed(() => {
})
const filteredOptions = computed(() => {
if (!searchQuery.value || !props.searchable) {
if (!searchQuery.value || !props.searchable || props.disableSearchFilter) {
return optionsWithKeys.value
}