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

Commit df40f1e

Browse files
committed
fix multi-select dropdown component w.r.t. api call
1 parent 4e60ebe commit df40f1e

3 files changed

Lines changed: 32 additions & 14 deletions

File tree

frontend/src/components/shared/MultiSelectModalDropdown/MultiSelectModalDropdown.jsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const MultiSelectModalDropdown = ({
66
onClose,
77
title,
88
placeholder,
9+
searchValue,
910
onSearchChange,
1011
suggestions,
1112
selectedItems,
@@ -36,7 +37,10 @@ const MultiSelectModalDropdown = ({
3637
if (isSelected) {
3738
onDeselect(item);
3839
} else {
39-
onSelect(item);
40+
// Prevent duplicate selection
41+
if (!selectedItems.some(selected => selected.id === item.id)) {
42+
onSelect(item);
43+
}
4044
}
4145
};
4246

@@ -48,6 +52,11 @@ const MultiSelectModalDropdown = ({
4852
return selectedItems.some(selected => selected.id === item.id);
4953
};
5054

55+
// Filter out already selected items from suggestions
56+
const availableSuggestions = suggestions.filter(item =>
57+
!selectedItems.some(selected => selected.id === item.id)
58+
);
59+
5160
if (!isOpen) return null;
5261

5362
return (
@@ -98,7 +107,7 @@ const MultiSelectModalDropdown = ({
98107
Loading...
99108
</div>
100109
)}
101-
{!loading && suggestions.map((item) => (
110+
{!loading && availableSuggestions.map((item) => (
102111
<div
103112
key={item.id}
104113
onClick={() => handleItemToggle(item)}
@@ -113,7 +122,7 @@ const MultiSelectModalDropdown = ({
113122
<span className={styles.itemText}>{item.display_name}</span>
114123
</div>
115124
))}
116-
{!loading && suggestions.length === 0 && inputValue.length >= minSearchLength && (
125+
{!loading && availableSuggestions.length === 0 && inputValue.length >= minSearchLength && (
117126
<div className={styles.noResults}>
118127
{noResultsMessage}
119128
</div>

frontend/src/components/shared/SearchForm.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,14 @@ const SearchForm = ({
5050

5151
return (
5252
<div style={{
53-
background: '#1a1a1a',
53+
background: 'rgba(26, 26, 26, 0.25)',
54+
backdropFilter: 'blur(4px)',
5455
borderRadius: 16,
5556
boxShadow: '0 4px 24px rgba(0,0,0,0.3)',
5657
padding: 32,
5758
maxWidth: 900,
5859
margin: '0 auto 2rem auto',
59-
border: '1px solid #404040'
60+
border: '1px solid rgba(64, 64, 64, 0.2)'
6061
}}>
6162
<form onSubmit={e => { e.preventDefault(); onSearch(); }} style={{ display: 'flex', flexDirection: 'column', gap: 20 }}>
6263
<div style={labelStyle}>
@@ -143,7 +144,7 @@ const SearchForm = ({
143144
<button
144145
type="button"
145146
style={{
146-
background: '#1a1a1a',
147+
background: 'rgba(26, 26, 26, 0.15)',
147148
color: '#4F6AF6',
148149
border: '1px solid #4F6AF6',
149150
borderRadius: 8,

frontend/src/pages/search_light.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -557,12 +557,16 @@ const SearchPageLight = ({ darkMode = true }) => {
557557
// Return a mock suggestions array for the multi-select component
558558
return Promise.resolve(filtered);
559559
}}
560-
suggestions={publicationTypes.filter(pt =>
561-
!selectedPublicationTypes.some(selected => selected.id === pt.id)
562-
)}
560+
suggestions={publicationTypes}
563561
selectedItems={selectedPublicationTypes}
564562
onSelect={(publicationType) => {
565-
setSelectedPublicationTypes(prev => [...prev, publicationType]);
563+
setSelectedPublicationTypes(prev => {
564+
// Prevent duplicate selection
565+
if (prev.some(pt => pt.id === publicationType.id)) {
566+
return prev;
567+
}
568+
return [...prev, publicationType];
569+
});
566570
}}
567571
onDeselect={(publicationType) => {
568572
setSelectedPublicationTypes(prev =>
@@ -580,12 +584,16 @@ const SearchPageLight = ({ darkMode = true }) => {
580584
title="Select Journals"
581585
placeholder="Type to search journals..."
582586
onSearchChange={searchJournals}
583-
suggestions={journalSuggestions.filter(journal =>
584-
!selectedJournals.some(selected => selected.id === journal.id)
585-
)}
587+
suggestions={journalSuggestions}
586588
selectedItems={selectedJournals}
587589
onSelect={(journal) => {
588-
setSelectedJournals(prev => [...prev, journal]);
590+
setSelectedJournals(prev => {
591+
// Prevent duplicate selection
592+
if (prev.some(j => j.id === journal.id)) {
593+
return prev;
594+
}
595+
return [...prev, journal];
596+
});
589597
}}
590598
onDeselect={(journal) => {
591599
setSelectedJournals(prev =>

0 commit comments

Comments
 (0)