Fix ESLint react-hooks/exhaustive-deps warning in ConsolidationModal

This commit is contained in:
Jordan Ramos
2026-05-22 11:19:46 -06:00
parent 6b805ee633
commit 76667f65c6

View File

@@ -279,16 +279,17 @@ export default function ConsolidationModal({ items, onClose, onSuccess }) {
const [submitting, setSubmitting] = useState(false); const [submitting, setSubmitting] = useState(false);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Initialize / regenerate form fields when selectedItems changes // Initialize form fields on mount from the original items prop.
// Uses items (prop) not selectedItems (state) to avoid re-triggering on removal.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
useEffect(() => { useEffect(() => {
if (selectedItems.length >= 2) { if (items.length >= 2) {
setSummary(generateConsolidatedSummary(selectedItems)); setSummary(generateConsolidatedSummary(items));
setDescription(generateConsolidatedDescription(selectedItems)); setDescription(generateConsolidatedDescription(items));
setCveId(extractFirstCve(selectedItems)); setCveId(extractFirstCve(items));
setVendor(extractCommonVendor(selectedItems)); setVendor(extractCommonVendor(items));
} }
}, []); // Only on mount — user edits are preserved after item removal }, [items]);
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Remove an item from the selection (minimum 2 required) // Remove an item from the selection (minimum 2 required)