Skip to content

Commit 2d60b92

Browse files
frano-mclaude
andauthored
fix: improve tooltip ux with delay and better placement (#775) (#776)
Co-authored-by: Fran McDade <18710366+frano-m@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f83617c commit 2d60b92

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

src/components/Filter/components/FilterLabel/filterLabel.stories.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { FilterLabel } from "./filterLabel";
55

66
const meta = {
77
argTypes: {
8+
annotation: { control: "object" },
89
count: { control: "number" },
910
disabled: { control: "boolean" },
1011
isOpen: { control: "boolean" },
@@ -27,6 +28,11 @@ type Story = StoryObj<typeof meta>;
2728

2829
export const FilterLabelStory: Story = {
2930
args: {
31+
annotation: {
32+
description:
33+
"This is a description of the filter label that provides additional context to the user.",
34+
label: "Label",
35+
},
3036
count: 123,
3137
disabled: false,
3238
isOpen: false,

src/components/Filter/components/FilterLabel/filterLabel.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ export const FilterLabel = ({
2626
}: FilterLabelProps): JSX.Element => {
2727
const filterLabel = count ? `${label}\xa0(${count})` : label; // When the count is present, a non-breaking space is used to prevent it from being on its own line
2828
return (
29-
<Tooltip description={annotation?.description} title={annotation?.label}>
29+
<Tooltip
30+
description={annotation?.description}
31+
enterDelay={300}
32+
placement="right"
33+
title={annotation?.label}
34+
>
3035
<StyledButton
3136
color="inherit"
3237
disabled={disabled}

src/components/Filter/components/Filters/stories/constants.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ const PROCESSED = {
105105
* Biological Sex select category view
106106
*/
107107
export const BIOLOGICAL_SEX: SelectCategoryView = {
108+
annotation: {
109+
description:
110+
"The biological sex of the donor organism, typically determined by chromosomal composition.",
111+
label: "Biological Sex",
112+
},
108113
key: "biologicalSex",
109114
label: "Biological Sex",
110115
values: [MALE, FEMALE],
@@ -114,6 +119,11 @@ export const BIOLOGICAL_SEX: SelectCategoryView = {
114119
* Genus Species select category view
115120
*/
116121
export const GENUS_SPECIES: SelectCategoryView = {
122+
annotation: {
123+
description:
124+
"The scientific name of the organism from which the sample was derived.",
125+
label: "Genus Species",
126+
},
117127
key: "genusSpecies",
118128
label: "Genus Species",
119129
values: [HOMO_SAPIENS, MUS_MUSCLES],
@@ -123,7 +133,11 @@ export const GENUS_SPECIES: SelectCategoryView = {
123133
* Donor Count range category view
124134
*/
125135
export const DONOR_COUNT: RangeCategoryView = {
126-
key: "Donor Count",
136+
annotation: {
137+
description: "The number of unique donors contributing to the dataset.",
138+
label: "Donor Count",
139+
},
140+
key: "donorCount",
127141
label: "Donor Count",
128142
max: 200,
129143
min: 10,
@@ -135,6 +149,11 @@ export const DONOR_COUNT: RangeCategoryView = {
135149
* File Format select category view
136150
*/
137151
export const FILE_FORMAT: SelectCategoryView = {
152+
annotation: {
153+
description:
154+
"The format of the file, such as BAM, CSV, FASTQ, or TSV, indicating how the data is structured.",
155+
label: "File Format",
156+
},
138157
key: "fileFormat",
139158
label: "File Format",
140159
values: [BAM, CSV, FASTQ, TSV],
@@ -144,6 +163,11 @@ export const FILE_FORMAT: SelectCategoryView = {
144163
* File Type select category view
145164
*/
146165
export const FILE_TYPE: SelectCategoryView = {
166+
annotation: {
167+
description:
168+
"The type of file, indicating whether the data is raw or has been processed.",
169+
label: "File Type",
170+
},
147171
isDisabled: true,
148172
key: "fileType",
149173
label: "File Type",

src/components/common/Tabs/tabs.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ function buildTabLabel(
8181
annotation?: DataDictionaryAnnotation,
8282
): ReactElement {
8383
return (
84-
<Tooltip description={annotation?.description} title={annotation?.label}>
84+
<Tooltip
85+
description={annotation?.description}
86+
enterDelay={300}
87+
title={annotation?.label}
88+
>
8589
<span>{count ? `${label} (${count})` : label}</span>
8690
</Tooltip>
8791
);

0 commit comments

Comments
 (0)