mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 18:52:19 +00:00
Revert "fix: add tab semantics to filter picker"
This reverts commit 103aa9e261d01cd7f086d1044cda8c9b871b6cb9.
This commit is contained in:
committed by
Christian Byrne
parent
a09ec49770
commit
2d6138b09e
@@ -1,27 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col space-y-2">
|
<div class="flex flex-col space-y-2">
|
||||||
<div
|
<div
|
||||||
ref="tablistRef"
|
|
||||||
class="flex flex-wrap gap-2"
|
class="flex flex-wrap gap-2"
|
||||||
role="tablist"
|
role="tablist"
|
||||||
:aria-label="$t('sideToolbar.nodeLibraryTab.filterCategory')"
|
:aria-label="$t('sideToolbar.nodeLibraryTab.filterCategory')"
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
v-for="(filterOption, index) in filters"
|
v-for="filterOption in filters"
|
||||||
:key="filterOption.id"
|
:key="filterOption.id"
|
||||||
type="button"
|
type="button"
|
||||||
size="sm"
|
size="sm"
|
||||||
role="tab"
|
|
||||||
:tabindex="selectedFilter?.id === filterOption.id ? 0 : -1"
|
|
||||||
:variant="
|
:variant="
|
||||||
selectedFilter?.id === filterOption.id
|
selectedFilter?.id === filterOption.id
|
||||||
? 'secondary'
|
? 'secondary'
|
||||||
: 'muted-textonly'
|
: 'muted-textonly'
|
||||||
"
|
"
|
||||||
class="flex-1 justify-center px-3 py-2 text-sm"
|
class="flex-1 justify-center px-3 py-2 text-sm"
|
||||||
:aria-selected="selectedFilter?.id === filterOption.id"
|
:aria-pressed="selectedFilter?.id === filterOption.id"
|
||||||
@click="selectFilterOption(filterOption)"
|
@click="selectFilterOption(filterOption)"
|
||||||
@keydown="onFilterKeydown($event, index)"
|
|
||||||
>
|
>
|
||||||
{{ filterOption.name }}
|
{{ filterOption.name }}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -41,7 +37,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import Select from 'primevue/select'
|
import Select from 'primevue/select'
|
||||||
import { computed, nextTick, onMounted, ref } from 'vue'
|
import { computed, onMounted, ref } from 'vue'
|
||||||
|
|
||||||
import Button from '@/components/ui/button/Button.vue'
|
import Button from '@/components/ui/button/Button.vue'
|
||||||
import type { ComfyNodeDefImpl } from '@/stores/nodeDefStore'
|
import type { ComfyNodeDefImpl } from '@/stores/nodeDefStore'
|
||||||
@@ -52,7 +48,6 @@ const filters = computed(() => nodeDefStore.nodeSearchService.nodeFilters)
|
|||||||
const selectedFilter = ref<FuseFilter<ComfyNodeDefImpl, string>>()
|
const selectedFilter = ref<FuseFilter<ComfyNodeDefImpl, string>>()
|
||||||
const filterValues = computed(() => selectedFilter.value?.fuseSearch.data ?? [])
|
const filterValues = computed(() => selectedFilter.value?.fuseSearch.data ?? [])
|
||||||
const selectedFilterValue = ref<string>('')
|
const selectedFilterValue = ref<string>('')
|
||||||
const tablistRef = ref<HTMLElement | null>(null)
|
|
||||||
|
|
||||||
const nodeDefStore = useNodeDefStore()
|
const nodeDefStore = useNodeDefStore()
|
||||||
|
|
||||||
@@ -85,51 +80,6 @@ const selectFilterOption = (
|
|||||||
updateSelectedFilterValue()
|
updateSelectedFilterValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
const focusFilterAtIndex = (index: number) => {
|
|
||||||
nextTick(() => {
|
|
||||||
const tabs = tablistRef.value?.querySelectorAll<HTMLElement>('[role="tab"]')
|
|
||||||
tabs?.[index]?.focus()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const onFilterKeydown = (event: KeyboardEvent, currentIndex: number) => {
|
|
||||||
const total = filters.value.length
|
|
||||||
if (!total) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let targetIndex: number | null = null
|
|
||||||
switch (event.key) {
|
|
||||||
case 'ArrowRight':
|
|
||||||
case 'ArrowDown':
|
|
||||||
targetIndex = (currentIndex + 1) % total
|
|
||||||
break
|
|
||||||
case 'ArrowLeft':
|
|
||||||
case 'ArrowUp':
|
|
||||||
targetIndex = (currentIndex - 1 + total) % total
|
|
||||||
break
|
|
||||||
case 'Home':
|
|
||||||
targetIndex = 0
|
|
||||||
break
|
|
||||||
case 'End':
|
|
||||||
targetIndex = total - 1
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targetIndex === null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
event.preventDefault()
|
|
||||||
const targetFilter = filters.value[targetIndex]
|
|
||||||
if (targetFilter) {
|
|
||||||
selectFilterOption(targetFilter)
|
|
||||||
focusFilterAtIndex(targetIndex)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const submit = () => {
|
const submit = () => {
|
||||||
if (!selectedFilter.value) {
|
if (!selectedFilter.value) {
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user