Skip to content

Commit

Permalink
fix(search): Show selected option in dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
annelhote committed Jan 17, 2025
1 parent 63eea06 commit 3dfe41b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 37 deletions.
13 changes: 9 additions & 4 deletions client/src/components/mention-list/item.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Badge, Button, Col, Row, Text } from '@dataesr/dsfr-plus';
import PropTypes from 'prop-types';
import { useState } from 'react';
import { Badge, Button, Col, Link, Row, Text } from '@dataesr/dsfr-plus';

import { getIdLink } from '../../utils/works';

export default function MentionListItem({ mention, index, selected, toggleToSelected }) {
export default function MentionListItem({ mention }) {
const [expanded, setExpanded] = useState(false);

const getIdLinkDisplay = (idType, idValue) => {
Expand All @@ -15,10 +17,9 @@ export default function MentionListItem({ mention, index, selected, toggleToSele

return (
<li key={mention.id}>

<Row>
<Col>
<input type="checkbox" selected={selected} />
<input type="checkbox" selected={mention.selected} />
</Col>
<Col md={8}>
<strong>
Expand Down Expand Up @@ -108,3 +109,7 @@ export default function MentionListItem({ mention, index, selected, toggleToSele
</li>
);
}

MentionListItem.propTypes = {
mention: PropTypes.object.isRequired,
};
12 changes: 4 additions & 8 deletions client/src/pages/datasets/search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,12 @@ export default function DatasetsSearch() {
buttonLabel={currentSearchParams.startYear}
label="Start year"
onSelectionChange={(startYear) => setSearchParams({ ...currentSearchParams, startYear })}
selectedKey={currentSearchParams.startYear}
>
{years.map((year) => (
<SelectOption
color="blue-cumulus"
key={year.value}
selected={
year.value === currentSearchParams.startYear
}
>
{year.label}
</SelectOption>
Expand All @@ -260,14 +258,12 @@ export default function DatasetsSearch() {
buttonLabel={currentSearchParams.endYear}
label="End year"
onSelectionChange={(endYear) => setSearchParams({ ...currentSearchParams, endYear })}
selectedKey={currentSearchParams.endYear}
>
{years.map((year) => (
<SelectOption
color="blue-cumulus"
key={year.value}
selected={
year.value === currentSearchParams.startYear
}
>
{year.label}
</SelectOption>
Expand Down Expand Up @@ -365,12 +361,12 @@ export default function DatasetsSearch() {
buttonLabel={currentSearchParams.startYear}
label="Start year"
onSelectionChange={(startYear) => setSearchParams({ ...currentSearchParams, startYear })}
selectedKey={currentSearchParams.startYear}
>
{years.map((year) => (
<SelectOption
color="blue-cumulus"
key={year.value}
selected={year.value === currentSearchParams.startYear}
>
{year.label}
</SelectOption>
Expand All @@ -383,12 +379,12 @@ export default function DatasetsSearch() {
buttonLabel={currentSearchParams.endYear}
label="End year"
onSelectionChange={(endYear) => setSearchParams({ ...currentSearchParams, endYear })}
selectedKey={currentSearchParams.endYear}
>
{years.map((year) => (
<SelectOption
color="blue-cumulus"
key={year.value}
selected={year.value === currentSearchParams.startYear}
>
{year.label}
</SelectOption>
Expand Down
3 changes: 1 addition & 2 deletions client/src/pages/mentions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -852,9 +852,8 @@ export default function Mentions() {
</Button>
</div>
<ul style={{ listStyle: 'none' }}>
{mentions.map((mention, index) => (
{mentions.map((mention) => (
<MentionListItem
index={index}
key={mention.id}
mention={mention}
/>
Expand Down
9 changes: 2 additions & 7 deletions client/src/pages/openalex-affiliations/results/list-view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,12 @@ export default function ListView({
<select
className="fr-select"
id="select-sort-on-number-of-rors"
onChange={(e) => {
setSelectSortOnNumberOfRors(e.target.value);
}}
onChange={(e) => setSelectSortOnNumberOfRors(e.target.value)}
value={selectSortOnNumberOfRors}
>
<option value="default">Works descending (default)</option>
<option value="numberASC">ROR ascending</option>
<option value="numberDESC">ROR descending</option>
{/* <option value="empty">No ROR detected</option> */}
</select>
</label>
</div>
Expand Down Expand Up @@ -389,9 +386,7 @@ export default function ListView({
<select
className="fr-select"
id="select-ror-country"
onChange={(e) => {
setSelectRorCountry(e.target.value);
}}
onChange={(e) => setSelectRorCountry(e.target.value)}
value={selectRorCountry}
>
<option value="all">All countries</option>
Expand Down
12 changes: 4 additions & 8 deletions client/src/pages/openalex-affiliations/search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,12 @@ export default function Search() {
buttonLabel={currentSearchParams.startYear}
label="Start year"
onSelectionChange={(startYear) => setSearchParams({ ...currentSearchParams, startYear })}
selectedKey={currentSearchParams.startYear}
>
{years.map((year) => (
<SelectOption
color="blue-cumulus"
key={year.value}
selected={
year.value === currentSearchParams.startYear
}
>
{year.label}
</SelectOption>
Expand All @@ -288,14 +286,12 @@ export default function Search() {
buttonLabel={currentSearchParams.endYear}
label="End year"
onSelectionChange={(endYear) => setSearchParams({ ...currentSearchParams, endYear })}
selectedKey={currentSearchParams.endYear}
>
{years.map((year) => (
<SelectOption
color="blue-cumulus"
key={year.value}
selected={
year.value === currentSearchParams.startYear
}
>
{year.label}
</SelectOption>
Expand Down Expand Up @@ -381,12 +377,12 @@ export default function Search() {
buttonLabel={currentSearchParams.startYear}
label="Start year"
onSelectionChange={(startYear) => setSearchParams({ ...currentSearchParams, startYear })}
selectedKey={currentSearchParams.startYear}
>
{years.map((year) => (
<SelectOption
color="blue-cumulus"
key={year.value}
selected={year.value === currentSearchParams.startYear}
>
{year.label}
</SelectOption>
Expand All @@ -399,12 +395,12 @@ export default function Search() {
buttonLabel={currentSearchParams.endYear}
label="End year"
onSelectionChange={(endYear) => setSearchParams({ ...currentSearchParams, endYear })}
selectedKey={currentSearchParams.endYear}
>
{years.map((year) => (
<SelectOption
color="blue-cumulus"
key={year.value}
selected={year.value === currentSearchParams.startYear}
>
{year.label}
</SelectOption>
Expand Down
12 changes: 4 additions & 8 deletions client/src/pages/publications/search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,12 @@ export default function PublicationsSearch() {
buttonLabel={currentSearchParams.startYear}
label="Start year"
onSelectionChange={(startYear) => setSearchParams({ ...currentSearchParams, startYear })}
selectedKey={currentSearchParams.startYear}
>
{years.map((year) => (
<SelectOption
color="blue-cumulus"
key={year.value}
selected={
year.value === currentSearchParams.startYear
}
>
{year.label}
</SelectOption>
Expand All @@ -261,14 +259,12 @@ export default function PublicationsSearch() {
buttonLabel={currentSearchParams.endYear}
label="End year"
onSelectionChange={(endYear) => setSearchParams({ ...currentSearchParams, endYear })}
selectedKey={currentSearchParams.endYear}
>
{years.map((year) => (
<SelectOption
color="blue-cumulus"
key={year.value}
selected={
year.value === currentSearchParams.startYear
}
>
{year.label}
</SelectOption>
Expand Down Expand Up @@ -369,12 +365,12 @@ export default function PublicationsSearch() {
buttonLabel={currentSearchParams.startYear}
label="Start year"
onSelectionChange={(startYear) => setSearchParams({ ...currentSearchParams, startYear })}
selectedKey={currentSearchParams.startYear}
>
{years.map((year) => (
<SelectOption
color="blue-cumulus"
key={year.value}
selected={year.value === currentSearchParams.startYear}
>
{year.label}
</SelectOption>
Expand All @@ -387,12 +383,12 @@ export default function PublicationsSearch() {
buttonLabel={currentSearchParams.endYear}
label="End year"
onSelectionChange={(endYear) => setSearchParams({ ...currentSearchParams, endYear })}
selectedKey={currentSearchParams.endYear}
>
{years.map((year) => (
<SelectOption
color="blue-cumulus"
key={year.value}
selected={year.value === currentSearchParams.startYear}
>
{year.label}
</SelectOption>
Expand Down

0 comments on commit 3dfe41b

Please sign in to comment.