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