mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-24 14:45:36 +00:00
## Summary
Fixes two visual bugs in the Desktop app at small window sizes: the
search bar getting pushed/clipped in modal headers, and autocomplete
suggestion dropdowns being cut off by `overflow-hidden` ancestors.
## Changes
- **`SearchAutocomplete.vue`**: Wrap `ComboboxContent` in
`ComboboxPortal` so the suggestions dropdown teleports to `<body>`,
escaping `overflow-hidden` ancestors (fixes z-index clipping in Manager
dialog and other modals using `BaseModalLayout`)
- **`BaseModalLayout.vue`**: Replace `shrink-0` with `min-w-0` on the
header content container so the search bar can shrink at narrow window
sizes instead of overflowing and being clipped by the modal root's
`overflow-hidden`
- **`GraphCanvas.vue`**: Fix dead code where the native drag
(`app-drag`) div was nested inside a `v-if="workflowTabsPosition ===
'Topbar'"` block with its own mutually exclusive condition — move it
before the block and add `pointer-events-auto` so Desktop window
dragging works when tabs are in Sidebar position
## Why no E2E tests
- **`SearchAutocomplete` portal**: The fix is structural (teleport to
`<body>`). A meaningful regression test would require opening the
Manager dialog with a real or mocked extension list — that is a
substantial standalone effort tracked in #11714.
- **`BaseModalLayout` header shrink**: A viewport-resize assertion would
test CSS layout behaviour, not application logic; it would be fragile
and low-value.
- **`GraphCanvas` app-drag**: Desktop/Electron-only.
`-webkit-app-region: drag` cannot be exercised in headless Chromium.
Unit tests for `SearchAutocomplete` cover the new code paths (portal
rendering, suggestion display, item selection).
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Low Risk**
> Low risk UI-only changes: adjusts layout CSS and combobox rendering
via `ComboboxPortal`, plus adds unit tests; no business logic or data
flow changes.
>
> **Overview**
> Fixes small-window Desktop UI issues where modal-header search inputs
could be clipped and autocomplete dropdowns could be cut off by
`overflow-hidden` ancestors.
>
> `SearchAutocomplete` now renders its suggestions list inside a
`ComboboxPortal` (teleporting the popper content outside clipping
containers) and adds a focused unit test suite covering empty/non-empty
suggestions, selection behavior, and `optionLabel` handling.
>
> `BaseModalLayout` tweaks header flexbox constraints (`min-w-0` on the
header content container) to allow the search bar to shrink instead of
overflowing.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
fd32d960f9. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Benjamin Lu <benjaminlu1107@gmail.com>
246 lines
6.9 KiB
Vue
246 lines
6.9 KiB
Vue
<template>
|
|
<div
|
|
:class="cn('relative overflow-hidden rounded-2xl', sizeClasses)"
|
|
@keydown.esc.capture="handleEscape"
|
|
>
|
|
<div
|
|
class="grid size-full transition-[grid-template-columns] duration-300 ease-out"
|
|
:style="gridStyle"
|
|
>
|
|
<nav
|
|
class="flex h-full flex-col overflow-hidden bg-modal-panel-background"
|
|
:inert="!showLeftPanel"
|
|
:aria-hidden="!showLeftPanel"
|
|
>
|
|
<header
|
|
data-component-id="LeftPanelHeader"
|
|
class="flex h-18 w-full shrink-0 items-center-safe gap-2 pr-3 pl-6"
|
|
>
|
|
<slot name="leftPanelHeaderTitle" />
|
|
<Button
|
|
v-if="!notMobile && showLeftPanel"
|
|
size="lg"
|
|
class="ml-auto w-10 p-0"
|
|
:aria-label="t('g.hideLeftPanel')"
|
|
@click="toggleLeftPanel"
|
|
>
|
|
<i class="icon-[lucide--panel-left-close]" />
|
|
</Button>
|
|
</header>
|
|
<slot name="leftPanel" />
|
|
</nav>
|
|
|
|
<div class="flex flex-col overflow-hidden bg-base-background">
|
|
<header
|
|
v-if="$slots.header"
|
|
class="flex h-18 w-full items-center justify-between gap-2 px-6"
|
|
>
|
|
<div class="flex min-w-0 flex-1 gap-2">
|
|
<Button
|
|
v-if="!notMobile && !showLeftPanel"
|
|
size="lg"
|
|
class="w-10 p-0"
|
|
:aria-label="t('g.showLeftPanel')"
|
|
@click="toggleLeftPanel"
|
|
>
|
|
<i class="icon-[lucide--panel-left]" />
|
|
</Button>
|
|
<slot name="header" />
|
|
</div>
|
|
<slot name="header-right-area" />
|
|
<template v-if="!isRightPanelOpen">
|
|
<Button
|
|
v-if="hasRightPanel"
|
|
size="lg"
|
|
class="w-10 p-0"
|
|
:aria-label="t('g.showRightPanel')"
|
|
@click="toggleRightPanel"
|
|
>
|
|
<i class="icon-[lucide--panel-right] size-4" />
|
|
</Button>
|
|
<Button
|
|
size="lg"
|
|
class="w-10"
|
|
:aria-label="t('g.closeDialog')"
|
|
@click="closeDialog"
|
|
>
|
|
<i class="pi pi-times" />
|
|
</Button>
|
|
</template>
|
|
</header>
|
|
|
|
<main class="flex min-h-0 flex-1 flex-col">
|
|
<slot name="contentFilter" />
|
|
<h2
|
|
v-if="!hasLeftPanel"
|
|
class="text-xxl m-0 px-6 pt-2 pb-6 capitalize select-none"
|
|
>
|
|
{{ contentTitle }}
|
|
</h2>
|
|
<div :class="contentContainerClass">
|
|
<slot name="content" />
|
|
</div>
|
|
</main>
|
|
</div>
|
|
|
|
<aside
|
|
v-if="hasRightPanel"
|
|
class="overflow-hidden"
|
|
:inert="!isRightPanelOpen"
|
|
:aria-hidden="!isRightPanelOpen"
|
|
>
|
|
<div
|
|
class="flex h-full w-72 min-w-72 flex-col bg-modal-panel-background"
|
|
>
|
|
<header
|
|
data-component-id="RightPanelHeader"
|
|
class="flex h-18 shrink-0 items-center gap-2 px-6"
|
|
>
|
|
<h2
|
|
v-if="rightPanelTitle"
|
|
class="flex-1 text-base font-semibold select-none"
|
|
>
|
|
{{ rightPanelTitle }}
|
|
</h2>
|
|
<div v-else class="flex-1">
|
|
<slot name="rightPanelHeaderTitle" />
|
|
</div>
|
|
<slot name="rightPanelHeaderActions" />
|
|
<Button
|
|
size="lg"
|
|
class="w-10 p-0"
|
|
:aria-label="t('g.hideRightPanel')"
|
|
@click="toggleRightPanel"
|
|
>
|
|
<i class="icon-[lucide--panel-right-close] size-4" />
|
|
</Button>
|
|
<Button
|
|
size="lg"
|
|
class="w-10 p-0"
|
|
:aria-label="t('g.closeDialog')"
|
|
@click="closeDialog"
|
|
>
|
|
<i class="pi pi-times" />
|
|
</Button>
|
|
</header>
|
|
<div class="min-h-0 flex-1 overflow-y-auto">
|
|
<slot name="rightPanel" />
|
|
</div>
|
|
</div>
|
|
</aside>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { useBreakpoints } from '@vueuse/core'
|
|
import { computed, inject, ref, useSlots, watch } from 'vue'
|
|
import { useI18n } from 'vue-i18n'
|
|
|
|
import Button from '@/components/ui/button/Button.vue'
|
|
import { OnCloseKey } from '@/types/widgetTypes'
|
|
import { cn } from '@comfyorg/tailwind-utils'
|
|
|
|
const { t } = useI18n()
|
|
|
|
const SIZE_CLASSES = {
|
|
sm: 'h-[80vh] w-[90vw] max-w-[960px]',
|
|
md: 'h-[80vh] w-[90vw] max-w-[1400px]',
|
|
lg: 'h-[80vh] w-[90vw] max-w-[1280px] aspect-[20/13] min-[1450px]:max-w-[1724px]',
|
|
full: 'h-full w-full max-w-[1400px] 2xl:max-w-[1600px]'
|
|
} as const
|
|
|
|
type ModalSize = keyof typeof SIZE_CLASSES
|
|
type ContentPadding = 'default' | 'compact' | 'none'
|
|
|
|
const {
|
|
contentTitle,
|
|
rightPanelTitle,
|
|
size = 'lg',
|
|
leftPanelWidth = '14rem',
|
|
contentPadding = 'default'
|
|
} = defineProps<{
|
|
contentTitle: string
|
|
rightPanelTitle?: string
|
|
size?: ModalSize
|
|
leftPanelWidth?: string
|
|
contentPadding?: ContentPadding
|
|
}>()
|
|
|
|
const sizeClasses = computed(() => SIZE_CLASSES[size])
|
|
|
|
const isRightPanelOpen = defineModel<boolean>('rightPanelOpen', {
|
|
default: false
|
|
})
|
|
|
|
const slots = useSlots()
|
|
const hasLeftPanel = computed(() => !!slots.leftPanel)
|
|
const hasRightPanel = computed(() => !!slots.rightPanel)
|
|
|
|
const BREAKPOINTS = { md: 880 }
|
|
|
|
const closeDialog = inject(OnCloseKey, () => {})
|
|
|
|
const breakpoints = useBreakpoints(BREAKPOINTS)
|
|
const notMobile = breakpoints.greater('md')
|
|
|
|
const isLeftPanelOpen = ref<boolean>(true)
|
|
const mobileMenuOpen = ref<boolean>(false)
|
|
|
|
watch(notMobile, (isDesktop) => {
|
|
if (!isDesktop) {
|
|
mobileMenuOpen.value = false
|
|
}
|
|
})
|
|
|
|
const showLeftPanel = computed(() => {
|
|
const shouldShow = notMobile.value
|
|
? isLeftPanelOpen.value
|
|
: mobileMenuOpen.value
|
|
return shouldShow
|
|
})
|
|
|
|
const contentContainerClass = computed(() =>
|
|
cn(
|
|
'flex scrollbar-custom min-h-0 flex-1 flex-col overflow-y-auto',
|
|
contentPadding === 'default' && 'px-6 pt-0 pb-10',
|
|
contentPadding === 'compact' && 'px-6 pt-0 pb-2'
|
|
)
|
|
)
|
|
|
|
const gridStyle = computed(() => ({
|
|
gridTemplateColumns: hasRightPanel.value
|
|
? `${hasLeftPanel.value && showLeftPanel.value ? leftPanelWidth : '0rem'} 1fr ${isRightPanelOpen.value ? '18rem' : '0rem'}`
|
|
: `${hasLeftPanel.value && showLeftPanel.value ? leftPanelWidth : '0rem'} 1fr`
|
|
}))
|
|
|
|
const toggleLeftPanel = () => {
|
|
if (notMobile.value) {
|
|
isLeftPanelOpen.value = !isLeftPanelOpen.value
|
|
} else {
|
|
mobileMenuOpen.value = !mobileMenuOpen.value
|
|
}
|
|
}
|
|
|
|
const toggleRightPanel = () => {
|
|
isRightPanelOpen.value = !isRightPanelOpen.value
|
|
}
|
|
|
|
function handleEscape(event: KeyboardEvent) {
|
|
const target = event.target
|
|
if (!(target instanceof HTMLElement)) return
|
|
if (
|
|
target instanceof HTMLInputElement ||
|
|
target instanceof HTMLTextAreaElement ||
|
|
target instanceof HTMLSelectElement ||
|
|
target.isContentEditable
|
|
) {
|
|
return
|
|
}
|
|
if (isRightPanelOpen.value) {
|
|
event.stopPropagation()
|
|
isRightPanelOpen.value = false
|
|
}
|
|
}
|
|
</script>
|