Skip to content
This repository was archived by the owner on Feb 6, 2026. It is now read-only.

Commit 7426f8c

Browse files
committed
fix AddComponentModal category collapsing
1 parent 406b5fd commit 7426f8c

2 files changed

Lines changed: 33 additions & 14 deletions

File tree

app/web/src/newhotness/AddComponentModal.vue

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@
8383
ref="scrollRef"
8484
class="grow min-h-0 scrollable"
8585
>
86+
<div
87+
v-if="virtualItems.length === 0 && fuzzySearchString.length > 0"
88+
class="w-full h-full flex flex-row items-center justify-center"
89+
>
90+
<EmptyState
91+
text="No components match your search."
92+
icon="component"
93+
noTopMargin
94+
/>
95+
</div>
8696
<div
8797
class="w-full relative flex flex-col"
8898
:style="{
@@ -117,7 +127,6 @@
117127
"
118128
@click="() => assetClick(row.index)"
119129
/>
120-
<!-- TODO: Fix indices for category is open -->
121130
</div>
122131
</div>
123132
</div>
@@ -714,13 +723,28 @@ const justCleared = ref(false);
714723
715724
watch([fuzzySearchString, selectedFilter], ([newFuzzySearchString]) => {
716725
updateDebouncedSearch(newFuzzySearchString);
726+
openAllCategories();
717727
});
718728
729+
const closeAllCategories = () => {
730+
categoryIsOpen.value = new Set();
731+
};
732+
733+
const openAllCategories = () => {
734+
filteredCategories.value.forEach((category) => {
735+
categoryIsOpen.value.add(category.name);
736+
});
737+
};
738+
719739
const toggleFilterTile = (name?: string) => {
720740
clearSelection();
721-
if (!name) selectedFilter.value = undefined;
722-
else if (selectedFilter.value === name) selectedFilter.value = undefined;
723-
else selectedFilter.value = name;
741+
if (!name || selectedFilter.value === name) {
742+
selectedFilter.value = undefined;
743+
nextTick(closeAllCategories);
744+
} else {
745+
selectedFilter.value = name;
746+
nextTick(openAllCategories);
747+
}
724748
};
725749
726750
const isFilterSelected = (name: string) => {
@@ -733,7 +757,7 @@ const resetModal = () => {
733757
fuzzySearchString.value = "";
734758
debouncedSearchString.value = "";
735759
bannerClosed.value = false;
736-
categoryIsOpen.value = new Set();
760+
closeAllCategories();
737761
selectedAsset.value = undefined;
738762
selectionIndex.value = undefined;
739763
toggleFilterTile();
@@ -785,9 +809,6 @@ const categoryFromVirtualRowIndex = (rowIdx: number) => {
785809
};
786810
787811
const openFromIndex = (idx: number) => {
788-
// if searching open everything
789-
if (selectedFilter.value || debouncedSearchString.value) return true;
790-
791812
const cat = categoryFromVirtualRowIndex(idx);
792813
if (!cat) return false;
793814
return categoryIsOpen.value.has(cat.name);
@@ -906,11 +927,7 @@ const categoryAndSchemaRows = computed(() => {
906927
color: category.color,
907928
});
908929
909-
if (
910-
selectedFilter.value ||
911-
debouncedSearchString.value ||
912-
categoryIsOpen.value.has(category.name)
913-
) {
930+
if (categoryIsOpen.value.has(category.name)) {
914931
category.assets.forEach((asset) => {
915932
rows.push({
916933
type: "schema",

app/web/src/newhotness/EmptyState.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
:class="
55
clsx(
66
!iconNoBg && [
7-
'mt-sm p-sm rounded-full',
7+
!noTopMargin && 'mt-sm',
8+
'p-sm rounded-full',
89
themeClasses('bg-neutral-200', 'bg-neutral-700'),
910
],
1011
)
@@ -75,6 +76,7 @@ const props = defineProps({
7576
icon: { type: String as PropType<IconNames>, required: true },
7677
iconSize: { type: String as PropType<IconSizes> },
7778
iconNoBg: { type: Boolean },
79+
noTopMargin: { type: Boolean },
7880
});
7981
8082
const emit = defineEmits<{

0 commit comments

Comments
 (0)