@centreon/ui 24.4.52 → 24.4.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "24.4.52",
3
+ "version": "24.4.54",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
@@ -1,4 +1,4 @@
1
- import { includes, map, prop, reject } from 'ramda';
1
+ import { includes, map, prop, reject, sortBy, toLower, compose } from 'ramda';
2
2
  import { makeStyles } from 'tss-react/mui';
3
3
 
4
4
  import { Chip, ChipProps, Tooltip } from '@mui/material';
@@ -85,9 +85,11 @@ const MultiAutocompleteField = ({
85
85
  return includes(id, valueIds);
86
86
  };
87
87
 
88
+ const sortByName = sortBy(compose(toLower, prop(optionProperty)));
89
+
88
90
  const autocompleteOptions = disableSortedOptions
89
91
  ? options
90
- : [...values, ...reject(isOptionSelected, options)];
92
+ : sortByName([...values, ...reject(isOptionSelected, options)]);
91
93
 
92
94
  return (
93
95
  <Autocomplete
@@ -222,7 +222,8 @@ const AutocompleteField = React.forwardRef(
222
222
  ...params.inputProps,
223
223
  'aria-label': label,
224
224
  'data-testid': dataTestId || label,
225
- id: getNormalizedId(label || '')
225
+ id: getNormalizedId(label || ''),
226
+ ...autocompleteProps?.inputProps
226
227
  }}
227
228
  label={label}
228
229
  placeholder={isNil(placeholder) ? t(searchLabel) : placeholder}
@@ -6,14 +6,16 @@ import {
6
6
  ClickAwayListener,
7
7
  Paper,
8
8
  Popper,
9
- PopperPlacementType,
10
- useTheme
9
+ PopperPlacementType
11
10
  } from '@mui/material';
12
11
  import { PopperProps } from '@mui/material/Popper';
13
12
 
14
13
  import { IconButton } from '..';
15
14
 
16
- const useStyles = makeStyles()(() => ({
15
+ const useStyles = makeStyles()((theme) => ({
16
+ popover: {
17
+ zIndex: theme.zIndex.tooltip
18
+ },
17
19
  popoverIconButton: {
18
20
  padding: 0,
19
21
  width: '100%'
@@ -52,7 +54,6 @@ const PopoverMenu = ({
52
54
  getPopoverData,
53
55
  popperProps
54
56
  }: Props): JSX.Element => {
55
- const theme = useTheme();
56
57
  const { classes, cx } = useStyles();
57
58
  const [anchorEl, setAnchorEl] = useState<HTMLElement | undefined>();
58
59
  const isOpen = Boolean(anchorEl);
@@ -105,9 +106,9 @@ const PopoverMenu = ({
105
106
  <Popper
106
107
  open
107
108
  anchorEl={anchorEl}
109
+ className={classes.popover}
108
110
  nonce={undefined}
109
111
  placement={popperPlacement}
110
- style={{ zIndex: theme.zIndex.tooltip }}
111
112
  onResize={(): undefined => undefined}
112
113
  onResizeCapture={(): undefined => undefined}
113
114
  {...popperProps}
@@ -1,10 +1,10 @@
1
1
  import { ForwardedRef, forwardRef, ReactElement, ReactNode } from 'react';
2
2
 
3
- import { ListItem as MuiListItem } from '@mui/material';
3
+ import { ListItemProps, ListItem as MuiListItem } from '@mui/material';
4
4
 
5
5
  import { useStyles } from './ListItem.styles';
6
6
 
7
- type ListItemProps = {
7
+ type Props = {
8
8
  action?: ReactElement;
9
9
  children: ReactNode | Array<ReactNode>;
10
10
  className?: string;
@@ -12,7 +12,7 @@ type ListItemProps = {
12
12
 
13
13
  export const ListItem = forwardRef(
14
14
  (
15
- { action, children, className, ...attr }: ListItemProps,
15
+ { action, children, className, ...attr }: Props & ListItemProps,
16
16
  ref?: ForwardedRef<HTMLLIElement>
17
17
  ) => {
18
18
  const { classes, cx } = useStyles();
@@ -22,6 +22,8 @@ const ChildComponent = (): JSX.Element => {
22
22
  <Button onClick={() => toggleFullscreen(document.body)}>
23
23
  {isFullscreenActivated ? labelExitFullscreen : labelEnterFullscreen}
24
24
  </Button>
25
+ <input id="input" />
26
+ <textarea id="textarea" />
25
27
  </div>
26
28
  );
27
29
  };
@@ -94,16 +96,35 @@ describe('Fullscreen', () => {
94
96
  .should('have.attr', 'data-fullscreenActivated', 'false')
95
97
  .should('have.attr', 'data-fullscreenEnabled', 'true');
96
98
 
97
- cy.get('#test').realPress(['Alt', 'F']);
99
+ cy.get('#test').realPress(['F']);
98
100
 
99
101
  cy.get('#test')
100
102
  .should('have.attr', 'data-fullscreenActivated', 'true')
101
103
  .should('have.attr', 'data-fullscreenEnabled', 'true');
102
104
 
103
- cy.get('#test').realPress(['Alt', 'F']);
105
+ cy.get('#test').realPress(['F']);
104
106
 
105
107
  cy.get('#test')
106
108
  .should('have.attr', 'data-fullscreenActivated', 'false')
107
109
  .should('have.attr', 'data-fullscreenEnabled', 'true');
108
110
  });
111
+
112
+ ['input', 'textarea'].forEach((tag) => {
113
+ it(`cannot toggle fullscreen feature using the shortcut when ${tag === 'input' ? 'an' : 'a'} ${tag} is focused`, () => {
114
+ initialize();
115
+
116
+ cy.get('#test')
117
+ .should('have.attr', 'data-fullscreenActivated', 'false')
118
+ .should('have.attr', 'data-fullscreenEnabled', 'true');
119
+
120
+ cy.get(`#${tag}`).focus();
121
+
122
+ cy.get('#test').realPress(['F']);
123
+
124
+ cy.get('#test')
125
+ .should('have.attr', 'data-fullscreenActivated', 'false')
126
+ .should('have.attr', 'data-fullscreenEnabled', 'true');
127
+ cy.get(`#${tag}`).should('have.value', 'F');
128
+ });
129
+ });
109
130
  });
@@ -1,6 +1,6 @@
1
1
  import { useEffect } from 'react';
2
2
 
3
- import { equals } from 'ramda';
3
+ import { equals, includes } from 'ramda';
4
4
  import { useSearchParams } from 'react-router-dom';
5
5
 
6
6
  import { useDeepCompare } from '../useMemoComponent';
@@ -16,7 +16,10 @@ export const useFullscreenListener = (): boolean => {
16
16
  useFullscreen();
17
17
 
18
18
  const toggle = (event: KeyboardEvent): void => {
19
- if (!event.altKey || !equals(event.code, 'KeyF')) {
19
+ if (
20
+ includes(document.activeElement?.tagName, ['INPUT', 'TEXTAREA']) ||
21
+ !equals(event.code, 'KeyF')
22
+ ) {
20
23
  return;
21
24
  }
22
25