Skip to content

Commit 8905f33

Browse files
committed
Load CSS for ResolutionMaster only when needed
CSS is now loaded dynamically when a ResolutionMaster node is created, preventing global style interference in ComfyUI. The css-loader.js module was updated to export a loadStylesWhenNeeded function, and ResolutionMaster.js was updated to import and call this function during node setup. Minor improvements were also made to height adjustment and tooltip redraw logic.
1 parent 90c5003 commit 8905f33

2 files changed

Lines changed: 20 additions & 10 deletions

File tree

js/ResolutionMaster.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ class ResolutionMasterCanvas {
7373
this.presetCategories = presetCategories;
7474

7575
this.setupNode();
76+
77+
// Load CSS only when this specific node instance is created
78+
// This prevents global CSS loading that affects entire ComfyUI
79+
import('./css-loader.js').then(module => {
80+
module.loadStylesWhenNeeded();
81+
}).catch(error => {
82+
log.error('Failed to load CSS:', error);
83+
});
7684
}
7785

7886
ensureMinimumSize() {
@@ -401,8 +409,9 @@ class ResolutionMasterCanvas {
401409
}
402410

403411
const neededHeight = currentY + 20;
404-
// Always adjust height to match content, allowing shrinking when sections are collapsed
405-
if (node.size[1] !== neededHeight) {
412+
// Only adjust height if difference is significant (avoid micro-adjustments causing redraws)
413+
const heightDiff = Math.abs(node.size[1] - neededHeight);
414+
if (heightDiff > 1) {
406415
node.size[1] = Math.max(neededHeight, node.min_size[1]);
407416
}
408417

@@ -1495,14 +1504,10 @@ class ResolutionMasterCanvas {
14951504
}
14961505
}
14971506

1498-
// Always update mouse position for tooltips
1507+
// Update mouse position for tooltips
14991508
this.tooltipMousePos = { x: e.canvasX, y: e.canvasY };
15001509

1501-
// If tooltip is showing, update canvas to follow mouse
1502-
if (this.showTooltip && this.tooltipElement) {
1503-
app.graph.setDirtyCanvas(true);
1504-
}
1505-
1510+
// Only trigger redraw if hover element changed
15061511
if (newHover !== this.hoverElement) {
15071512
this.hoverElement = newHover;
15081513
this.handleTooltipHover(newHover, e);

js/css-loader.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,10 @@ export function loadAllStyles() {
4141
}
4242
}
4343

44-
// Auto-load styles when this module is imported
45-
loadAllStyles();
44+
/**
45+
* Call this function when the ResolutionMaster node is actually created/used
46+
* to load styles only when needed, preventing global UI interference
47+
*/
48+
export function loadStylesWhenNeeded() {
49+
loadAllStyles();
50+
}

0 commit comments

Comments
 (0)