mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-01 19:20:10 +00:00
feat: scroll to specific setting when opening settings dialog (#8761)
## Summary - Adds `settingId` parameter to `showSettingsDialog` that auto-navigates to the correct category tab, scrolls to the setting, and briefly highlights it with a CSS pulse animation - Adds `data-setting-id` attributes to setting items for stable DOM targeting - Adds "Don't show this again" checkbox with "Re-enable in Settings" deep-link to the missing nodes dialog - Adds "Re-enable in Settings" deep-link to missing models and blueprint overwrite "Don't show this again" checkboxes - Fixes #3437 ## Test plan - [x] `pnpm typecheck` passes - [x] `pnpm lint` passes - [x] Unit tests pass (59/59 including 5 new tests for `useSettingUI`) https://github.com/user-attachments/assets/a9e80aea-7b69-4686-b030-55a2e0570ff0 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8761-feat-scroll-to-specific-setting-when-opening-settings-dialog-3036d73d365081d18d9afe9f9ed41ebc) by [Unito](https://www.unito.io)
This commit is contained in:
committed by
GitHub
parent
19a724710c
commit
e411a104f4
@@ -112,7 +112,7 @@ import Listbox from 'primevue/listbox'
|
||||
import ScrollPanel from 'primevue/scrollpanel'
|
||||
import TabPanels from 'primevue/tabpanels'
|
||||
import Tabs from 'primevue/tabs'
|
||||
import { computed, watch } from 'vue'
|
||||
import { computed, nextTick, onBeforeUnmount, watch } from 'vue'
|
||||
|
||||
import SearchBox from '@/components/common/SearchBox.vue'
|
||||
import CurrentUserMessage from '@/components/dialog/content/setting/CurrentUserMessage.vue'
|
||||
@@ -129,7 +129,7 @@ import type { SettingTreeNode } from '@/platform/settings/settingStore'
|
||||
import type { ISettingGroup, SettingParams } from '@/platform/settings/types'
|
||||
import { flattenTree } from '@/utils/treeUtil'
|
||||
|
||||
const { defaultPanel } = defineProps<{
|
||||
const { defaultPanel, scrollToSettingId } = defineProps<{
|
||||
defaultPanel?:
|
||||
| 'about'
|
||||
| 'keybinding'
|
||||
@@ -140,6 +140,7 @@ const { defaultPanel } = defineProps<{
|
||||
| 'subscription'
|
||||
| 'workspace'
|
||||
| 'secrets'
|
||||
scrollToSettingId?: string
|
||||
}>()
|
||||
|
||||
const { flags } = useFeatureFlags()
|
||||
@@ -153,7 +154,7 @@ const {
|
||||
settingCategories,
|
||||
groupedMenuTreeNodes,
|
||||
panels
|
||||
} = useSettingUI(defaultPanel)
|
||||
} = useSettingUI(defaultPanel, scrollToSettingId)
|
||||
|
||||
const {
|
||||
searchQuery,
|
||||
@@ -202,6 +203,31 @@ const tabValue = computed<string>(() =>
|
||||
inSearch.value ? 'Search Results' : (activeCategory.value?.label ?? '')
|
||||
)
|
||||
|
||||
// Scroll to and highlight the target setting once the correct tab renders.
|
||||
if (scrollToSettingId) {
|
||||
const stopScrollWatch = watch(
|
||||
tabValue,
|
||||
() => {
|
||||
void nextTick(() => {
|
||||
const el = document.querySelector(
|
||||
`[data-setting-id="${CSS.escape(scrollToSettingId)}"]`
|
||||
)
|
||||
if (!el) return
|
||||
stopScrollWatch()
|
||||
el.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
||||
el.classList.add('setting-highlight')
|
||||
el.addEventListener(
|
||||
'animationend',
|
||||
() => el.classList.remove('setting-highlight'),
|
||||
{ once: true }
|
||||
)
|
||||
})
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
onBeforeUnmount(stopScrollWatch)
|
||||
}
|
||||
|
||||
// Don't allow null category to be set outside of search.
|
||||
// In search mode, the active category can be null to show all search results.
|
||||
watch(activeCategory, (_, oldValue) => {
|
||||
@@ -218,6 +244,26 @@ watch(activeCategory, (_, oldValue) => {
|
||||
.settings-tab-panels {
|
||||
padding-top: 0 !important;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.setting-highlight {
|
||||
animation: setting-highlight-pulse 1.5s ease-in-out;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes setting-highlight-pulse {
|
||||
0%,
|
||||
100% {
|
||||
background-color: transparent;
|
||||
}
|
||||
30% {
|
||||
background-color: color-mix(
|
||||
in srgb,
|
||||
var(--p-primary-color) 15%,
|
||||
transparent
|
||||
);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user