Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.

Commit 7fbd9e0

Browse files
authored
Merge pull request #187 from DigitalProductInnovationAndDevelopment/development
Development
2 parents b71f7b4 + 223b845 commit 7fbd9e0

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

frontend/src/pages/collaboration_graph.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ const GraphViewLight = ({ darkMode = true }) => {
4848
}
4949
}, [graphData]);
5050

51-
// Global keyboard listener for Enter key to generate graph
51+
// Global keyboard listener for Enter key to generate graph (multi-select logic)
5252
useEffect(() => {
5353
const handleGlobalKeyDown = (e) => {
5454
// Only trigger if Enter is pressed and we're not in a modal input
5555
if (e.key === 'Enter' && !showAuthorModal && !showInstitutionModal) {
56-
// Check if we have the required fields to generate the graph
57-
if (selectedInstitution && (searchTerm.trim() || selectedAuthor)) {
56+
// Trigger if at least one institution is selected
57+
if (selectedInstitutions.length > 0) {
5858
setTriggerSearch(s => !s);
5959
setHasSearched(true);
6060
}
@@ -63,7 +63,7 @@ const GraphViewLight = ({ darkMode = true }) => {
6363

6464
document.addEventListener('keydown', handleGlobalKeyDown);
6565
return () => document.removeEventListener('keydown', handleGlobalKeyDown);
66-
}, [selectedInstitution, searchTerm, selectedAuthor, showAuthorModal, showInstitutionModal]);
66+
}, [selectedInstitutions, showAuthorModal, showInstitutionModal]);
6767

6868
// Author autocomplete suggestions
6969
useEffect(() => {
@@ -323,19 +323,22 @@ const GraphViewLight = ({ darkMode = true }) => {
323323
}
324324
};
325325

326-
// Handle Enter key in modal inputs
326+
// Handle Enter key in modal inputs for multi-select
327327
const handleModalKeyDown = (e, modalType) => {
328328
if (e.key === 'Enter') {
329329
if (modalType === 'author' && modalAuthorSuggestions.length > 0) {
330-
// Select the first author suggestion
330+
// Add the first author suggestion if not already selected
331331
const firstAuthor = modalAuthorSuggestions[0];
332-
setSelectedAuthor(firstAuthor);
333-
setAuthorInput(firstAuthor.display_name);
332+
if (!selectedAuthors.some(a => a.id === firstAuthor.id)) {
333+
setSelectedAuthors([...selectedAuthors, firstAuthor]);
334+
}
334335
setShowAuthorModal(false);
335336
} else if (modalType === 'institution' && modalInstitutionSuggestions.length > 0) {
336-
// Select the first institution suggestion
337+
// Add the first institution suggestion if not already selected
337338
const firstInstitution = modalInstitutionSuggestions[0];
338-
setSelectedInstitution(firstInstitution);
339+
if (!selectedInstitutions.some(i => i.id === firstInstitution.id)) {
340+
setSelectedInstitutions([...selectedInstitutions, firstInstitution]);
341+
}
339342
setShowInstitutionModal(false);
340343
}
341344
}

0 commit comments

Comments
 (0)