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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user