Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pfam filter button issues #1284

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/libs/coreui/src/components/inputs/SelectList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default function SelectList<T extends string>({
);
}

// Returns button display content based on `value` array, mapping to display names from `items` when available.
// Returns button display content based on `value` array, mapping to altDisplay, display, or value from `items` in that order of preference.
// If no matching display name is found, uses the value itself. Returns `defaultContent` if `value` is empty.
function getDisplayContent<T extends string>(
value: T[],
Expand All @@ -117,9 +117,10 @@ function getDisplayContent<T extends string>(
): ReactNode {
return value.length
? value
.map<ReactNode>(
(v) => items.find((item) => item.value === v)?.display ?? v
)
.map<ReactNode>((v) => {
const item = items.find((item) => item.value === v);
return item?.altDisplay ?? item?.display ?? v;
})
.reduce((accum, elem) => (accum ? [accum, ',', elem] : elem), null)
: defaultContent;
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export type Item<T> = {
display: ReactNode;
value: T;
disabled?: boolean;
/** an optional alternative display - perhaps a shortened version for use in popover buttons */
altDisplay?: ReactNode;
};

export type CheckboxListProps<T extends string> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ export function RecordTable_Sequences(
</div>
),
value: formatAttributeValue(row.accession),
// unexciting display for the popover button:
altDisplay: formatAttributeValue(row.accession),
}))}
value={volatilePfamFilterIds}
onChange={(ids) => {
Expand Down
Loading