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

Commit 7e84044

Browse files
committed
feat(F-155): Implement Clear Author and Institution Fields on Search, Topic Trends and World Map Pages
1 parent fafd29b commit 7e84044

6 files changed

Lines changed: 60 additions & 1 deletion

File tree

frontend/src/components/shared/DropdownTrigger/DropdownTrigger.jsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,32 @@ const DropdownTrigger = ({
55
value,
66
placeholder,
77
onClick,
8+
onClear,
89
darkMode = false,
910
disabled = false
1011
}) => {
1112
return (
1213
<div
1314
className={`${styles.triggerContainer} ${darkMode ? styles.dark : ''} ${disabled ? styles.disabled : ''}`}
1415
onClick={disabled ? undefined : onClick}
15-
style={{ cursor: disabled ? 'not-allowed' : 'pointer' }}
16+
style={{ cursor: disabled ? 'not-allowed' : 'pointer', position: 'relative' }}
1617
>
1718
<span className={styles.triggerText}>
1819
{value || placeholder}
1920
</span>
21+
{value && onClear && (
22+
<button
23+
className={styles.clearButton}
24+
onClick={e => {
25+
e.stopPropagation();
26+
onClear();
27+
}}
28+
aria-label="Clear"
29+
tabIndex={0}
30+
>
31+
×
32+
</button>
33+
)}
2034
<span className={styles.triggerArrow}></span>
2135
</div>
2236
);

frontend/src/components/shared/DropdownTrigger/DropdownTrigger.module.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,27 @@
4343
transition: transform 0.15s;
4444
}
4545

46+
.clearButton {
47+
position: absolute;
48+
right: 2rem;
49+
background: none;
50+
border: none;
51+
color: #aaa;
52+
font-size: 1.1rem;
53+
cursor: pointer;
54+
padding: 0 0.25rem;
55+
z-index: 2;
56+
line-height: 1;
57+
top: 50%;
58+
transform: translateY(-50%);
59+
display: flex;
60+
align-items: center;
61+
justify-content: center;
62+
}
63+
.clearButton:hover {
64+
color: #f44336;
65+
}
66+
4667
.triggerContainer:hover .triggerArrow {
4768
color: #4F6AF6;
4869
}

frontend/src/components/shared/SearchForm.jsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ const SearchForm = ({
88
searchKeyword,
99
setSearchKeyword,
1010
author,
11+
setAuthor,
12+
setAuthorObject,
1113
institution,
14+
setInstitution,
15+
setInstitutionObject,
1216
onSearch,
1317
onOpenAdvancedFilters,
1418
onAuthorClick,
@@ -100,6 +104,10 @@ const SearchForm = ({
100104
value={author}
101105
placeholder="Click to search authors..."
102106
onClick={onAuthorClick}
107+
onClear={author ? () => {
108+
setAuthor("");
109+
if (typeof setAuthorObject === 'function') setAuthorObject(null);
110+
} : undefined}
103111
darkMode={darkMode}
104112
/>
105113
</div>
@@ -116,6 +124,10 @@ const SearchForm = ({
116124
value={institution}
117125
placeholder="Click to search institutions..."
118126
onClick={onInstitutionClick}
127+
onClear={institution ? () => {
128+
setInstitution("");
129+
if (typeof setInstitutionObject === 'function') setInstitutionObject(null);
130+
} : undefined}
119131
darkMode={darkMode}
120132
/>
121133
</div>

frontend/src/pages/search.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,11 @@ const SearchPageLight = ({ darkMode = true }) => {
369369
searchKeyword={searchKeyword}
370370
setSearchKeyword={setSearchKeyword}
371371
author={author}
372+
setAuthor={setAuthor}
373+
setAuthorObject={setAuthorObject}
372374
institution={institution}
375+
setInstitution={setInstitution}
376+
setInstitutionObject={setInstitutionObject}
373377
onSearch={handleSearch}
374378
onOpenAdvancedFilters={() => setShowAdvanced(true)}
375379
onAuthorClick={() => {

frontend/src/pages/trend_graphs.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,11 @@ export const PositionDetailLight = ({ darkMode = true }) => {
426426
searchKeyword={searchKeyword}
427427
setSearchKeyword={setSearchKeyword}
428428
author={author}
429+
setAuthor={setAuthor}
430+
setAuthorObject={setAuthorObject}
429431
institution={institution}
432+
setInstitution={setInstitution}
433+
setInstitutionObject={setInstitutionObject}
430434
onSearch={handleSearch}
431435
onOpenAdvancedFilters={() => setShowAdvanced(true)}
432436
onAuthorClick={() => {

frontend/src/pages/world_map.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,11 @@ const WorldMapPapersPage = () => {
208208
searchKeyword={searchKeyword}
209209
setSearchKeyword={setSearchKeyword}
210210
author={author}
211+
setAuthor={setAuthor}
212+
setAuthorObject={setAuthorObject}
211213
institution={institution}
214+
setInstitution={setInstitution}
215+
setInstitutionObject={setInstitutionObject}
212216
onSearch={handleSearch}
213217
onOpenAdvancedFilters={() => setShowAdvanced(true)}
214218
onAuthorClick={() => {

0 commit comments

Comments
 (0)