Skip to content

Commit fb38349

Browse files
authored
bump focus-trap-react (#872)
* bump focus-trap-react * Configure focustrap for legacy timing issues w/ enzyme
1 parent deefeae commit fb38349

3 files changed

Lines changed: 29 additions & 21 deletions

File tree

package-lock.json

Lines changed: 13 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "clever-components",
3-
"version": "2.235.0",
3+
"version": "2.236.0",
44
"description": "A library of helpful React components and less styles",
55
"repository": {
66
"type": "git",
@@ -26,7 +26,7 @@
2626
"classnames": "~2.2.5",
2727
"core-js": "^2.4.1",
2828
"downshift": "6.1.3",
29-
"focus-trap-react": "^7.0.1",
29+
"focus-trap-react": "^10.3.1",
3030
"less": "^3.8.1",
3131
"linkify-it": "^3.0.2",
3232
"lodash": "^4.14.1",

src/Modal/Modal.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,20 @@ export class Modal extends React.Component<Props, State> {
112112
let modal;
113113
if (this.props.focusLocked) {
114114
modal = (
115-
<FocusTrap focusTrapOptions={{ initialFocus: '[aria-label="close modal window"]' }}>
115+
<FocusTrap
116+
focusTrapOptions={{
117+
checkCanFocusTrap: async (containers) => {
118+
const hasFocusTarget = containers.some((container) =>
119+
container.matches('[aria-label="close modal window"]'),
120+
);
121+
if (!hasFocusTarget) {
122+
await new Promise((resolve) => setTimeout(resolve, 100));
123+
}
124+
},
125+
initialFocus: '[aria-label="close modal window"]',
126+
delayInitialFocus: true,
127+
}}
128+
>
116129
{modalContent}
117130
</FocusTrap>
118131
);

0 commit comments

Comments
 (0)