Skip to content

Commit 0266986

Browse files
committed
chore(deps): in-house focusTrap
1 parent c9e82d1 commit 0266986

File tree

25 files changed

+197
-157
lines changed

25 files changed

+197
-157
lines changed

packages/react-core/package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,7 @@
4343
"@patternfly/react-icons": "^3.15.13",
4444
"@patternfly/react-styles": "^3.7.10",
4545
"@patternfly/react-tokens": "^2.8.10",
46-
"emotion": "^9.2.9",
47-
"exenv": "^1.2.2",
48-
"focus-trap-react": "^4.0.1",
46+
"focus-trap": "4.0.2",
4947
"react-dropzone": "9.0.0",
5048
"tippy.js": "5.1.2"
5149
},
@@ -59,7 +57,6 @@
5957
"@babel/preset-env": "^7.0.0",
6058
"@babel/preset-react": "^7.0.0",
6159
"@patternfly/patternfly": "2.70.1",
62-
"@types/exenv": "^1.2.0",
6360
"@types/jest": "^24.0.11",
6461
"@types/react": "^16.4.0",
6562
"@types/react-dom": "^16.4.0",

packages/react-core/src/components/AboutModal/AboutModalContainer.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import * as React from 'react';
2-
3-
// eslint-disable-next-line @typescript-eslint/no-var-requires
4-
const FocusTrap: any = require('focus-trap-react');
5-
6-
import styles from '@patternfly/react-styles/css/layouts/Bullseye/bullseye';
72
import { css } from '@patternfly/react-styles';
3+
import styles from '@patternfly/react-styles/css/layouts/Bullseye/bullseye';
4+
import { FocusTrap } from '../../helpers';
85

96
import { AboutModalBoxContent } from './AboutModalBoxContent';
107
import { AboutModalBoxHeader } from './AboutModalBoxHeader';

packages/react-core/src/components/AboutModal/__tests__/AboutModalBoxCloseButton.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ test('AboutModalBoxCloseButton Test onclose', () => {
1414
});
1515

1616
test('AboutModalBoxCloseButton Test close button aria label', () => {
17-
const closeButtonAriaLabel = 'Klose Daylok'
17+
const closeButtonAriaLabel = 'Klose Daylok';
1818
const view = shallow(<AboutModalBoxCloseButton aria-label={closeButtonAriaLabel} />);
1919
expect(view).toMatchSnapshot();
2020
});

packages/react-core/src/components/AboutModal/__tests__/__snapshots__/AboutModalContainer.test.tsx.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
exports[`About Modal Container Test isOpen 1`] = `
44
<Backdrop>
55
<FocusTrap
6-
_createFocusTrap={[Function]}
76
active={true}
87
className="pf-l-bullseye"
98
focusTrapOptions={
@@ -12,7 +11,6 @@ exports[`About Modal Container Test isOpen 1`] = `
1211
}
1312
}
1413
paused={false}
15-
tag="div"
1614
>
1715
<AboutModalBox
1816
aria-describedby="ariaDescribedById"

packages/react-core/src/components/Alert/__tests__/Alert.test.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ Object.values(AlertVariant).forEach(variant => {
4747
test('Action Close Button', () => {
4848
const onClose = jest.fn();
4949
const view = mount(
50-
<Alert variant={variant} action={<AlertActionCloseButton aria-label="Close" onClose={onClose} />} title={`Sample ${variant} alert`}>
50+
<Alert
51+
variant={variant}
52+
action={<AlertActionCloseButton aria-label="Close" onClose={onClose} />}
53+
title={`Sample ${variant} alert`}
54+
>
5155
Some alert
5256
</Alert>
5357
);

packages/react-core/src/components/ContextSelector/ContextSelector.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ import { Button, ButtonVariant } from '../Button';
99
import { TextInput } from '../TextInput';
1010
import { InputGroup } from '../InputGroup';
1111
import { KEY_CODES } from '../../helpers/constants';
12-
13-
// Can't use ES6 imports :(
14-
// The types for it are also wrong, we should probably ditch this dependency.
15-
/* eslint-disable-next-line @typescript-eslint/no-var-requires */
16-
const FocusTrap: any = require('focus-trap-react');
12+
import { FocusTrap } from '../../helpers';
1713

1814
// seed for the aria-labelledby ID
1915
let currentId = 0;

packages/react-core/src/components/ContextSelector/__tests__/__snapshots__/ContextSelector.test.tsx.snap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,13 @@ exports[`Renders ContextSelector open 1`] = `
4141
className="pf-c-context-selector__menu"
4242
>
4343
<FocusTrap
44-
_createFocusTrap={[Function]}
4544
active={true}
4645
focusTrapOptions={
4746
Object {
4847
"clickOutsideDeactivates": true,
4948
}
5049
}
5150
paused={false}
52-
tag="div"
5351
>
5452
<div
5553
className="pf-c-context-selector__menu-input"
Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,44 @@
1-
import { Drawer, DrawerPanelContent, DrawerContent, DrawerHead, DrawerActions, DrawerCloseButton, DrawerContentBody, DrawerPanelBody} from '../';
1+
import {
2+
Drawer,
3+
DrawerPanelContent,
4+
DrawerContent,
5+
DrawerHead,
6+
DrawerActions,
7+
DrawerCloseButton,
8+
DrawerContentBody,
9+
DrawerPanelBody
10+
} from '../';
211
import React from 'react';
312
import { mount } from 'enzyme';
413

514
Object.values([
6-
{ isExpanded: true, isInline: false, isStatic:false },
7-
{ isExpanded: false, isInline: false, isStatic:false },
8-
{ isExpanded: true, isInline: true, isStatic:false },
9-
{ isExpanded: false, isInline: true, isStatic:false },
10-
{ isExpanded: true, isInline: false, isStatic:true}
15+
{ isExpanded: true, isInline: false, isStatic: false },
16+
{ isExpanded: false, isInline: false, isStatic: false },
17+
{ isExpanded: true, isInline: true, isStatic: false },
18+
{ isExpanded: false, isInline: true, isStatic: false },
19+
{ isExpanded: true, isInline: false, isStatic: true }
1120
]).forEach(({ isExpanded, isInline, isStatic }) => {
1221
const panelContent = (
13-
<DrawerPanelContent>
22+
<DrawerPanelContent>
1423
<DrawerHead>
1524
<span>drawer-panel</span>
1625
<DrawerActions>
17-
<DrawerCloseButton/>
26+
<DrawerCloseButton />
1827
</DrawerActions>
1928
</DrawerHead>
20-
<DrawerPanelBody>drawer-panel</DrawerPanelBody>
21-
</DrawerPanelContent>);
22-
const drawerContent =
29+
<DrawerPanelBody>drawer-panel</DrawerPanelBody>
30+
</DrawerPanelContent>
31+
);
32+
const drawerContent =
2333
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
2434
test(`Drawer isExpanded = ${isExpanded} and isInline = ${isInline} and isStatic = ${isStatic}`, () => {
2535
const view = mount(
2636
<Drawer isExpanded={isExpanded}>
27-
<DrawerContent panelContent={panelContent}>
28-
<DrawerContentBody>{drawerContent}</DrawerContentBody>
29-
</DrawerContent>
30-
</Drawer>);
37+
<DrawerContent panelContent={panelContent}>
38+
<DrawerContentBody>{drawerContent}</DrawerContentBody>
39+
</DrawerContent>
40+
</Drawer>
41+
);
3142
expect(view).toMatchSnapshot();
3243
});
3344
});

packages/react-core/src/components/Dropdown/__tests__/Dropdown.test.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -185,18 +185,20 @@ describe('API', () => {
185185
});
186186

187187
test('dropdownItems and children console error ', () => {
188-
const myMock = jest.fn();
189-
global.console = { error: myMock } as any;
190-
mount(
191-
<Dropdown
192-
dropdownItems={dropdownItems}
193-
isOpen
194-
toggle={<DropdownToggle id="Dropdown Toggle">Dropdown</DropdownToggle>}
195-
>
196-
<div>Children items</div>
197-
</Dropdown>
198-
)
199-
expect(myMock).toBeCalledWith('Children and dropdownItems props have been provided. Only the dropdownItems prop items will be rendered');
188+
const myMock = jest.fn();
189+
global.console = { error: myMock } as any;
190+
mount(
191+
<Dropdown
192+
dropdownItems={dropdownItems}
193+
isOpen
194+
toggle={<DropdownToggle id="Dropdown Toggle">Dropdown</DropdownToggle>}
195+
>
196+
<div>Children items</div>
197+
</Dropdown>
198+
);
199+
expect(myMock).toBeCalledWith(
200+
'Children and dropdownItems props have been provided. Only the dropdownItems prop items will be rendered'
201+
);
200202
});
201203

202204
test('dropdownItems only, no console error ', () => {

packages/react-core/src/components/FileUpload/__tests__/FileUpload.test.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ test('simple fileupload', () => {
77
const readStartedHandler = jest.fn();
88
const readFinishedHandler = jest.fn();
99

10-
const view = shallow(<FileUpload
11-
id="simple-text-file"
12-
type="text"
13-
value={''}
14-
filename={''}
15-
onChange={changeHandler}
16-
onReadStarted={readStartedHandler}
17-
onReadFinished={readFinishedHandler}
18-
isLoading={false}
19-
/>);
10+
const view = shallow(
11+
<FileUpload
12+
id="simple-text-file"
13+
type="text"
14+
value={''}
15+
filename={''}
16+
onChange={changeHandler}
17+
onReadStarted={readStartedHandler}
18+
onReadFinished={readFinishedHandler}
19+
isLoading={false}
20+
/>
21+
);
2022
expect(view).toMatchSnapshot();
2123
});
22-

0 commit comments

Comments
 (0)