mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-09 23:20:04 +00:00
feat: automatically fit view when loading templates (#8749)
## Description When loading a template workflow, always call `fitView()` to ensure the template is properly framed within the viewport. This provides a better initial viewing experience for users. ## Problem Previously, templates with embedded viewport positions (`extra.ds`) would load at arbitrary positions, sometimes showing a blank canvas. Users had to navigate significantly to find the workflow content. ## Solution Added a single condition in `loadGraphData()` to check if `openSource === 'template'` and force `fitView()` when true, bypassing the saved viewport position. This change only affects template loading - normal workflow loading behavior remains unchanged. ## Changes - `src/scripts/app.ts`: Added condition to always call `fitView()` when loading templates ## Testing - Load various templates from the template selector - Verify the workflow is fully visible and centered on load - Verify normal workflow loading still respects saved positions ## Related - Fixes COM-14156 - Related to COM-10087 (Center view on workflow when loading templates - Done) ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8749-feat-automatically-fit-view-when-loading-templates-3016d73d36508167a63de2ae407de7b8) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -1250,7 +1250,10 @@ export class ComfyApp {
|
||||
restore_view &&
|
||||
useSettingStore().get('Comfy.EnableWorkflowViewRestore')
|
||||
) {
|
||||
if (graphData.extra?.ds) {
|
||||
// Always fit view for templates to ensure they're visible on load
|
||||
if (openSource === 'template') {
|
||||
useLitegraphService().fitView()
|
||||
} else if (graphData.extra?.ds) {
|
||||
this.canvas.ds.offset = graphData.extra.ds.offset
|
||||
this.canvas.ds.scale = graphData.extra.ds.scale
|
||||
|
||||
|
||||
Reference in New Issue
Block a user