|
1 | 1 | // Copyright (c) Cosmo Tech.
|
2 | 2 | // Licensed under the MIT license.
|
3 | 3 |
|
4 |
| -import { MenuItem, Grid, Stack, TextField } from '@mui/material'; |
| 4 | +import { MenuItem, Grid, Stack, TextField, Tooltip, Fade, Box } from '@mui/material'; |
5 | 5 | import makeStyles from '@mui/styles/makeStyles';
|
6 | 6 | import PropTypes from 'prop-types';
|
7 | 7 | import React from 'react';
|
@@ -42,13 +42,34 @@ export const BasicEnumInput = (props) => {
|
42 | 42 | sx={{ flexGrow: 1 }}
|
43 | 43 | select
|
44 | 44 | value={value}
|
45 |
| - onChange={(event) => { |
46 |
| - return changeEnumField(event.target.value); |
| 45 | + SelectProps={{ |
| 46 | + renderValue: (value) => <Box>{value}</Box>, // Prevent extra padding on selected value |
| 47 | + 'data-cy': `enum-input-select-${id}`, |
| 48 | + MenuProps: { 'data-cy': `enum-input-menu-${id}` }, |
47 | 49 | }}
|
| 50 | + onChange={(event) => changeEnumField(event.target.value)} |
48 | 51 | >
|
49 | 52 | {enumValues.map((option) => (
|
50 |
| - <MenuItem key={option.key} value={option.key} data-cy={option.key}> |
51 |
| - {option.value} |
| 53 | + <MenuItem |
| 54 | + key={option.key} |
| 55 | + value={option.key} |
| 56 | + data-cy={option.key} |
| 57 | + sx={{ p: '0px' }} // Remove default MenuItem padding to increase the hover area for the items tooltips |
| 58 | + > |
| 59 | + <Tooltip |
| 60 | + data-cy={`enum-input-value-tooltip-${option.key}`} |
| 61 | + title={option.tooltip} |
| 62 | + placement="right-end" |
| 63 | + TransitionComponent={Fade} |
| 64 | + TransitionProps={{ timeout: 600 }} |
| 65 | + > |
| 66 | + <Box |
| 67 | + // Extra padding on menu items to increase the hover area for the items tooltips |
| 68 | + sx={{ px: '16px', py: '6px', width: '100%' }} |
| 69 | + > |
| 70 | + {option.value} |
| 71 | + </Box> |
| 72 | + </Tooltip> |
52 | 73 | </MenuItem>
|
53 | 74 | ))}
|
54 | 75 | </TextField>
|
|
0 commit comments