fix(#337): Fix boolean logic bug in ReactFlowEditor (use || instead of ??)

- Nullish coalescing (??) doesn't work with booleans as expected
- When readOnly=false, ?? never evaluates right side (!selectedNode)
- Changed to logical OR (||) for correct disabled state calculation
- Added comprehensive tests verifying the fix:
  * readOnly=false with no selection: editing disabled
  * readOnly=false with selection: editing enabled
  * readOnly=true: editing always disabled
- Removed unused eslint-disable directive

Refs #337

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Jason Woltje
2026-02-05 16:08:55 -06:00
parent c30b4b1cc2
commit 3055bd2d85
2 changed files with 271 additions and 2 deletions

View File

@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
"use client";
import { useCallback, useEffect, useMemo, useState } from "react";
@@ -211,7 +210,7 @@ export function ReactFlowEditor({
);
const handleDeleteSelected = useCallback(() => {
if (readOnly ?? !selectedNode) return;
if (readOnly || !selectedNode) return;
if (onNodeDelete) {
onNodeDelete(selectedNode);