Skip to content

Commit d6ed163

Browse files
authored
Merge pull request #114 from SolidLabResearch/fix/112
Fix/112
2 parents f96ad26 + 68888c1 commit d6ed163

File tree

3 files changed

+55
-14
lines changed

3 files changed

+55
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717

1818
- Clear query cache at logout (#106)
1919
- Cypress test suite version updated to ^13.8.0 (#109)
20+
- Hovering over query menu now displays a tooltip with information instead of expanding inside the menu (#112)
2021

2122
### Fixed
2223

src/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function App() {
6868
<Resource
6969
key={query.id}
7070
name={query.id}
71-
options={{ label: query.name }}
71+
options={{ label: query.name, descr: query.description }}
7272
icon={IconProvider[query.icon]}
7373
list={TemplatedListResultTable}
7474
/>

src/components/InteractionLayout/SelectionMenu/SelectionMenu.jsx

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import React, { Component } from 'react';
12
import { useResourceDefinitions } from "ra-core";
23
import { DashboardMenuItem } from "ra-ui-materialui";
34
import { Menu } from "react-admin";
4-
import { ThemeProvider, createTheme } from "@mui/material";
5-
import { Component } from "react";
5+
import { ThemeProvider, createTheme, Tooltip, Box, Typography } from "@mui/material";
66

77
/**
88
* A custom menu as defined in React Admin for selecting the query the user whishes to execute.
@@ -12,13 +12,25 @@ function SelectionMenu() {
1212
const resources = useResourceDefinitions();
1313
return (
1414
<ThemeProvider theme={menuItemTheme}>
15-
<div style={{ height: '100%', overflowY: 'auto'}}>
16-
<Menu>
17-
<DashboardMenuItem />
18-
{Object.keys(resources).map((id) => (
19-
<Menu.ResourceItem key={id} name={id} />
20-
))}
21-
</Menu>
15+
<div style={{ height: '100%', overflowY: 'auto', backgroundColor: 'white' }}>
16+
<Menu>
17+
<DashboardMenuItem />
18+
{Object.keys(resources).map((id) => (
19+
<Tooltip
20+
key={id}
21+
placement="right"
22+
title={
23+
<TooltipContent
24+
title={resources[id].options.label}
25+
description={resources[id].options.descr} />
26+
}
27+
>
28+
<div >
29+
<Menu.ResourceItem name={id} />
30+
</div>
31+
</Tooltip>
32+
))}
33+
</Menu>
2234
</div>
2335
</ThemeProvider>
2436
);
@@ -39,15 +51,43 @@ const menuItemTheme = createTheme({
3951
verticalAlign: "middle",
4052
},
4153
"&:hover": {
42-
display: "inline-flex",
43-
overflow: "visible",
44-
whiteSpace: "normal" ,
45-
minWidth: "fit-content",
54+
display: "block",
55+
whiteSpace: "nowrap",
56+
textOverflow: "ellipsis",
4657
}
4758
},
4859
},
4960
}
5061
},
5162
});
5263

64+
65+
const TooltipContent = ({ title, description }) => (
66+
<React.Fragment>
67+
<Box
68+
sx={{
69+
width: 'fit-content',
70+
backgroundColor: '#6d6d6d',
71+
paddingX: 1,
72+
marginX: -1,
73+
74+
}}
75+
>
76+
<Typography variant="h6" component="div">
77+
{title}
78+
</Typography>
79+
80+
<Typography variant="body2" component="div"
81+
sx={{
82+
fontStyle: 'italic',
83+
marginTop: 1,
84+
}}
85+
>
86+
{description}
87+
</Typography>
88+
</Box>
89+
</React.Fragment>
90+
)
91+
92+
5393
export default SelectionMenu;

0 commit comments

Comments
 (0)