Fix ESLint react-hooks/exhaustive-deps warning in ConsolidationModal
This commit is contained in:
@@ -279,16 +279,17 @@ export default function ConsolidationModal({ items, onClose, onSuccess }) {
|
||||
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(() => {
|
||||
if (selectedItems.length >= 2) {
|
||||
setSummary(generateConsolidatedSummary(selectedItems));
|
||||
setDescription(generateConsolidatedDescription(selectedItems));
|
||||
setCveId(extractFirstCve(selectedItems));
|
||||
setVendor(extractCommonVendor(selectedItems));
|
||||
if (items.length >= 2) {
|
||||
setSummary(generateConsolidatedSummary(items));
|
||||
setDescription(generateConsolidatedDescription(items));
|
||||
setCveId(extractFirstCve(items));
|
||||
setVendor(extractCommonVendor(items));
|
||||
}
|
||||
}, []); // Only on mount — user edits are preserved after item removal
|
||||
}, [items]);
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Remove an item from the selection (minimum 2 required)
|
||||
|
||||
Reference in New Issue
Block a user