Repository navigation
Align Vue badge display order #15670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { render, screen } from '@testing-library/vue' | ||
| import { describe, expect, it } from 'vitest' | ||
|
|
||
| import NodeBadges from '@/renderer/extensions/vueNodes/components/NodeBadges.vue' | ||
|
|
||
| describe('NodeBadges', () => { | ||
| it('renders the Comfy badge after the core badges', () => { | ||
| render(NodeBadges, { | ||
| props: { | ||
| hasComfyBadge: true, | ||
| core: [{ text: '#1' }, { text: 'BETA' }], | ||
| extension: [] | ||
| } | ||
| }) | ||
|
|
||
| const coreBadge = screen.getByText('BETA') | ||
| const comfyBadge = screen.getByTestId('comfy-badge') | ||
| expect( | ||
| coreBadge.compareDocumentPosition(comfyBadge) & | ||
| Node.DOCUMENT_POSITION_FOLLOWING | ||
| ).toBeTruthy() | ||
| }) | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,8 @@ import type { NodeBadgeProps } from '@/renderer/extensions/vueNodes/components/N | |
| import { useCanvasStore } from '@/renderer/core/canvas/canvasStore' | ||
| import { useNodeDefStore } from '@/stores/nodeDefStore' | ||
| import { nodeBadges } from '@/systems/badgeSystem' | ||
| import { CORE_JOIN_ORDER } from '@/types/badgeData' | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SHOULD FIX — naming/doc drift. |
||
| import type { CoreBadgePart } from '@/types/badgeData' | ||
| import { NodeBadgeMode } from '@/types/nodeSource' | ||
| import { resolveNode } from '@/utils/litegraphUtil' | ||
|
|
||
|
|
@@ -33,7 +35,7 @@ export function usePartitionedBadges(nodeData: NodeState) { | |
| settingStore.get('Comfy.NodeBadge.NodeSourceBadgeMode') === | ||
| NodeBadgeMode.ShowAll | ||
|
|
||
| const core: NodeBadgeProps[] = [] | ||
| const coreByPart = new Map<CoreBadgePart, NodeBadgeProps>() | ||
| const extension: NodeBadgeProps[] = [] | ||
| const pricing: { required: string; rest?: string }[] = [] | ||
|
|
||
|
|
@@ -46,7 +48,7 @@ export function usePartitionedBadges(nodeData: NodeState) { | |
| continue | ||
| } | ||
| if (nodeDef?.isCoreNode && row.part === 'source') continue | ||
| core.push({ | ||
| coreByPart.set(row.part, { | ||
| text: row.part === 'lifecycle' ? trim(row.text, ['[', ']']) : row.text | ||
| }) | ||
| } | ||
|
|
@@ -58,7 +60,10 @@ export function usePartitionedBadges(nodeData: NodeState) { | |
|
|
||
| return { | ||
| hasComfyBadge: showComfyLogo && pricing.length === 0, | ||
| core, | ||
| core: CORE_JOIN_ORDER.flatMap((part) => { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SHOULD FIX — both renderers now do the same Map-and-reorder dance. Emitting |
||
| const badge = coreByPart.get(part) | ||
| return badge ? [badge] : [] | ||
| }), | ||
| extension, | ||
| pricing | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BLOCKER — this promoted test asserts a display order the app doesn't produce.
vueBadgeText(line 81) appends the Comfy logo after the core chips:But
NodeBadges.vuerenders the logo pill before the core pill (v-if="hasComfyBadge"block precedes thev-if="core.length"block). So for a core node under ShowAll the real render is🦊 #1 | BETA, while legacy draws#1 [BETA] 🦊. The test says#1 BETA 🦊and passes only because the helper puts the logo where the template doesn't.The other two promoted tests (custom node, ShowAll/HideBuiltIn) are genuine — this one isn't. Pick one:
it.failshere and note the logo position is the remaining gap, ororders core parts as id, lifecycle, source) and drop the logo from the helper, orNodeBadges.vueso the assertion becomes true.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correction: downgrading this from BLOCKER to SHOULD FIX.
The underlying observation is still accurate — I re-checked, and
NodeBadges.vuedoes render the logo pill before the core pill in a plain flex row (noorder-*/flex-row-reverse), while legacy puts🦊last inside the joined string.But your PR description already says you're preserving the separate logo treatment for core nodes, so the helper's concatenation is reasonably read as a serialization of the core chip sequence rather than a spatial claim — and the core ordering it guards is genuinely fixed by this PR. Nothing here is broken at runtime.
So: not blocking. Worth renaming the test (or adding a line to
vueBadgeText) so the next reader doesn't take#1 BETA 🦊as the rendered left-to-right order, since it isn't.