Fix SelectionPanel - click applies immediately, opens Info
Some checks failed
Build Docker Image / build (push) Has been cancelled

This commit is contained in:
Ruslan Bakiev
2026-01-26 14:49:55 +07:00
parent a48dcf24ee
commit 911de423f6
2 changed files with 21 additions and 38 deletions

View File

@@ -4,7 +4,7 @@
<div class="flex-shrink-0 p-4 border-b border-white/10"> <div class="flex-shrink-0 p-4 border-b border-white/10">
<div class="flex items-center justify-between mb-3"> <div class="flex items-center justify-between mb-3">
<h3 class="font-semibold text-base text-white">{{ title }}</h3> <h3 class="font-semibold text-base text-white">{{ title }}</h3>
<button class="btn btn-ghost btn-xs btn-circle text-white/60 hover:text-white" @click="closeDrawer"> <button class="btn btn-ghost btn-xs btn-circle text-white/60 hover:text-white" @click="emit('close')">
<Icon name="lucide:x" size="16" /> <Icon name="lucide:x" size="16" />
</button> </button>
</div> </div>
@@ -40,8 +40,7 @@
:product="item" :product="item"
selectable selectable
compact compact
:is-selected="drawerSelectedItem?.uuid === item.uuid" @select="onSelect(item)"
@select="onDrawerSelect(item)"
/> />
</div> </div>
</template> </template>
@@ -57,8 +56,7 @@
<HubCard <HubCard
:hub="item" :hub="item"
selectable selectable
:is-selected="drawerSelectedItem?.uuid === item.uuid" @select="onSelect(item)"
@select="onDrawerSelect(item)"
/> />
</div> </div>
</template> </template>
@@ -74,8 +72,7 @@
<SupplierCard <SupplierCard
:supplier="item" :supplier="item"
selectable selectable
:is-selected="drawerSelectedItem?.uuid === item.uuid" @select="onSelect(item)"
@select="onDrawerSelect(item)"
/> />
</div> </div>
</template> </template>
@@ -90,17 +87,6 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Footer with Apply button -->
<div class="flex-shrink-0 p-4 border-t border-white/10">
<button
class="btn btn-primary w-full"
:disabled="!drawerSelectedItem"
@click="onApplyFilter"
>
{{ $t('catalog.applyFilter') }}
</button>
</div>
</div> </div>
</template> </template>
@@ -124,20 +110,14 @@ const props = defineProps<{
}>() }>()
const emit = defineEmits<{ const emit = defineEmits<{
'select': [type: string, item: Item]
'close': []
'load-more': [] 'load-more': []
'hover': [uuid: string | null] 'hover': [uuid: string | null]
}>() }>()
const { t } = useI18n() const { t } = useI18n()
// Get drawer functions from useCatalogSearch
const {
drawerSelectedItem,
selectDrawerItem,
applyDrawerFilter,
closeDrawer
} = useCatalogSearch()
const searchQuery = ref('') const searchQuery = ref('')
const loadMoreSentinel = ref<HTMLElement | null>(null) const loadMoreSentinel = ref<HTMLElement | null>(null)
@@ -206,15 +186,10 @@ const filteredItems = computed(() => {
) )
}) })
// Select item in drawer (doesn't apply filter yet) // Select item and emit
const onDrawerSelect = (item: Item) => { const onSelect = (item: Item) => {
if (item.uuid && item.name) { if (props.selectMode && item.uuid) {
selectDrawerItem(item.uuid, item.name) emit('select', props.selectMode, item)
} }
} }
// Apply filter and close drawer
const onApplyFilter = () => {
applyDrawerFilter()
}
</script> </script>

View File

@@ -27,6 +27,8 @@
:loading="selectionLoading" :loading="selectionLoading"
:loading-more="selectionLoadingMore" :loading-more="selectionLoadingMore"
:has-more="selectionHasMore && !filterByBounds" :has-more="selectionHasMore && !filterByBounds"
@select="onSelectItem"
@close="onCloseDrawer"
@load-more="onLoadMore" @load-more="onLoadMore"
@hover="onHoverItem" @hover="onHoverItem"
/> />
@@ -114,7 +116,8 @@ const {
cancelSelect, cancelSelect,
openInfo, openInfo,
closeInfo, closeInfo,
setLabel setLabel,
closeDrawer
} = useCatalogSearch() } = useCatalogSearch()
// Info panel composable // Info panel composable
@@ -375,15 +378,20 @@ const onMapSelect = async (item: any) => {
setLabel(infoType, itemId, itemName) setLabel(infoType, itemId, itemName)
} }
// Handle selection from SelectionPanel // Handle selection from SelectionPanel - open Info and close drawer
const onSelectItem = (type: string, item: any) => { const onSelectItem = (type: string, item: any) => {
if (item.uuid && item.name) { if (item.uuid && item.name) {
// NEW: Open Info instead of selecting directly
openInfo(type as 'hub' | 'supplier' | 'offer', item.uuid) openInfo(type as 'hub' | 'supplier' | 'offer', item.uuid)
setLabel(type, item.uuid, item.name) setLabel(type, item.uuid, item.name)
closeDrawer()
} }
} }
// Close drawer
const onCloseDrawer = () => {
closeDrawer()
}
// Handle Info panel events // Handle Info panel events
const onInfoClose = () => { const onInfoClose = () => {
closeInfo() closeInfo()