Skip to content

Commit

Permalink
Fix searchbox dismissed when closing filter panel (#2196)
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-byrne authored Jan 8, 2025
1 parent 67e6df7 commit 73ecacf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
7 changes: 7 additions & 0 deletions browser_tests/fixtures/components/ComfyNodeSearchBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import { Locator, Page } from '@playwright/test'
export class ComfyNodeSearchFilterSelectionPanel {
constructor(public readonly page: Page) {}

get header() {
return this.page
.getByRole('dialog')
.locator('div')
.filter({ hasText: 'Add node filter condition' })
}

async selectFilterType(filterType: string) {
await this.page
.locator(
Expand Down
16 changes: 16 additions & 0 deletions browser_tests/nodeSearchBox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@ test.describe('Node search box', () => {
await expectFilterChips(comfyPage, ['MODEL'])
})

test('Outer click dismisses filter panel but keeps search box visible', async ({
comfyPage
}) => {
await comfyPage.searchBox.filterButton.click()
const panel = comfyPage.searchBox.filterSelectionPanel
await panel.header.waitFor({ state: 'visible' })
const panelBounds = await panel.header.boundingBox()
await comfyPage.page.mouse.click(panelBounds!.x - 10, panelBounds!.y - 10)

// Verify the filter selection panel is hidden
expect(panel.header).not.toBeVisible()

// Verify the node search dialog is still visible
expect(comfyPage.searchBox.input).toBeVisible()
})

test('Can add multiple filters', async ({ comfyPage }) => {
await comfyPage.searchBox.addFilter('MODEL', 'Input Type')
await comfyPage.searchBox.addFilter('CLIP', 'Output Type')
Expand Down
9 changes: 7 additions & 2 deletions src/components/searchbox/NodeSearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
class="filter-button z-10"
@click="nodeSearchFilterVisible = true"
/>
<Dialog v-model:visible="nodeSearchFilterVisible" class="min-w-96">
<Dialog
v-model:visible="nodeSearchFilterVisible"
class="min-w-96"
dismissable-mask
modal
@hide="reFocusInput"
>
<template #header>
<h3>Add node filter condition</h3>
</template>
Expand Down Expand Up @@ -140,7 +146,6 @@ onMounted(reFocusInput)
const onAddFilter = (filterAndValue: FilterAndValue) => {
nodeSearchFilterVisible.value = false
emit('addFilter', filterAndValue)
reFocusInput()
}
const onRemoveFilter = (event: Event, filterAndValue: FilterAndValue) => {
event.stopPropagation()
Expand Down

0 comments on commit 73ecacf

Please sign in to comment.