Skip to content

Commit

Permalink
Fix collapsed node textarea causes UI inconsistency (#2267)
Browse files Browse the repository at this point in the history
  • Loading branch information
webfiltered authored Jan 16, 2025
1 parent edd58cd commit 79fee6a
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
37 changes: 37 additions & 0 deletions browser_tests/assets/collapsed_multiline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"last_node_id": 1,
"last_link_id": 0,
"nodes": [
{
"id": 1,
"type": "CLIPTextEncode",
"pos": [20, 50],
"size": [400, 200],
"flags": { "collapsed": true },
"order": 0,
"mode": 0,
"inputs": [
{
"name": "clip",
"type": "CLIP",
"link": null,
"localized_name": "clip"
}
],
"outputs": [
{
"name": "CONDITIONING",
"type": "CONDITIONING",
"links": null,
"localized_name": "CONDITIONING"
}
],
"properties": {},
"widgets_values": ["Should not be displayed."]
}
],
"links": [],
"groups": [],
"config": {},
"version": 0.4
}
27 changes: 27 additions & 0 deletions browser_tests/domWidget.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { expect } from '@playwright/test'

import { comfyPageFixture as test } from './fixtures/ComfyPage'

test.describe('DOM Widget', () => {
test('Collapsed multiline textarea is not visible', async ({ comfyPage }) => {
await comfyPage.loadWorkflow('collapsed_multiline')

expect(comfyPage.page.locator('.comfy-multiline-input')).not.toBeVisible()
})

test('Multiline textarea correctly collapses', async ({ comfyPage }) => {
const multilineTextAreas = comfyPage.page.locator('.comfy-multiline-input')
const firstMultiline = multilineTextAreas.first()
const lastMultiline = multilineTextAreas.last()

await expect(firstMultiline).toBeVisible()
await expect(lastMultiline).toBeVisible()

const nodes = await comfyPage.getNodeRefsByType('CLIPTextEncode')
for (const node of nodes) {
await node.click('collapse')
}
await expect(firstMultiline).not.toBeVisible()
await expect(lastMultiline).not.toBeVisible()
})
})
6 changes: 6 additions & 0 deletions src/scripts/domWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,12 @@ LGraphNode.prototype.addDOMWidget = function <
element.dataset.collapsed = this.flags?.collapsed ? 'true' : 'false'
}

const { onConfigure } = this
this.onConfigure = function () {
onConfigure?.apply(this, arguments)
element.dataset.collapsed = this.flags?.collapsed ? 'true' : 'false'
}

const onRemoved = this.onRemoved
this.onRemoved = function () {
element.remove()
Expand Down

0 comments on commit 79fee6a

Please sign in to comment.