focus-trap-react 8.9.2 → 8.10.0
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/CHANGELOG.md +6 -0
- package/README.md +17 -1
- package/dist/focus-trap-react.js +5 -1
- package/package.json +20 -19
- package/src/focus-trap-react.js +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 8.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 659d44e: Bumps focus-trap to v6.8.1. The big new feature is opt-in Shadow DOM support in focus-trap (in tabbable), and new tabbable options exposed in a new `focusTrapOptions.tabbableOptions` configuration option.
|
|
8
|
+
|
|
3
9
|
## 8.9.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -141,7 +141,9 @@ ReactDOM.render(<Demo />, document.getElementById('root'));
|
|
|
141
141
|
|
|
142
142
|
Type: `Object`, optional
|
|
143
143
|
|
|
144
|
-
Pass any of the options available in
|
|
144
|
+
Pass any of the options available in focus-trap's [createOptions](https://github.com/focus-trap/focus-trap#createoptions).
|
|
145
|
+
|
|
146
|
+
> ⚠️ See notes about __[testing in JSDom](#testing-in-jsdom)__ (e.g. using Jest) if that's what you currently use.
|
|
145
147
|
|
|
146
148
|
#### active
|
|
147
149
|
|
|
@@ -169,6 +171,20 @@ If `containerElements` is subsequently updated (i.e. after the trap has been cre
|
|
|
169
171
|
|
|
170
172
|
Using `containerElements` does require the use of React refs which, by nature, will require at least one state update in order to get the resolved elements into the prop, resulting in at least one additional render. In the normal case, this is likely more than acceptable, but if you really want to optimize things, then you could consider [using focus-trap directly](https://codesandbox.io/s/focus-trapreact-containerelements-demos-v5ydi) (see `Trap2.js`).
|
|
171
173
|
|
|
174
|
+
## Help
|
|
175
|
+
|
|
176
|
+
### Testing in JSDom
|
|
177
|
+
|
|
178
|
+
> ⚠️ JSDom is not officially supported. Your mileage may vary, and tests may break from one release to the next (even a patch or minor release).
|
|
179
|
+
>
|
|
180
|
+
> This topic is just here to help with what we know may affect your tests.
|
|
181
|
+
|
|
182
|
+
In general, a focus trap is best tested in a full browser environment such as Cypress, Playwright, or Nightwatch where a full DOM is available.
|
|
183
|
+
|
|
184
|
+
Sometimes, that's not entirely desirable, and depending on what you're testing, you may be able to get away with using JSDom (e.g. via Jest), but you'll have to configure your traps using the `focusTrapOptions.tabbableOptions.displayCheck: 'none'` option.
|
|
185
|
+
|
|
186
|
+
See [Testing focus-trap in JSDom](https://github.com/focus-trap/focus-trap#testing-in-jsdom) for more details.
|
|
187
|
+
|
|
172
188
|
## Contributing
|
|
173
189
|
|
|
174
190
|
See [CONTRIBUTING](CONTRIBUTING.md).
|
package/dist/focus-trap-react.js
CHANGED
|
@@ -339,7 +339,11 @@ FocusTrap.propTypes = {
|
|
|
339
339
|
returnFocusOnDeactivate: PropTypes.bool,
|
|
340
340
|
setReturnFocus: PropTypes.oneOfType([PropTypes.instanceOf(ElementType), PropTypes.string, PropTypes.func]),
|
|
341
341
|
allowOutsideClick: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
|
|
342
|
-
preventScroll: PropTypes.bool
|
|
342
|
+
preventScroll: PropTypes.bool,
|
|
343
|
+
tabbableOptions: PropTypes.shape({
|
|
344
|
+
displayCheck: PropTypes.oneOf(['full', 'non-zero-area', 'none']),
|
|
345
|
+
getShadowRoot: PropTypes.oneOfType([PropTypes.bool, PropTypes.func])
|
|
346
|
+
})
|
|
343
347
|
}),
|
|
344
348
|
containerElements: PropTypes.arrayOf(PropTypes.instanceOf(ElementType)),
|
|
345
349
|
children: PropTypes.oneOfType([PropTypes.element, // React element
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "focus-trap-react",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.10.0",
|
|
4
4
|
"description": "A React component that traps focus.",
|
|
5
5
|
"main": "dist/focus-trap-react.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"test:cypress:ci": "start-server-and-test start 9966 'cypress run --browser $CYPRESS_BROWSER --headless'",
|
|
29
29
|
"test": "yarn format:check && yarn lint && yarn test:unit && yarn test:types && CYPRESS_BROWSER=chrome yarn test:cypress:ci",
|
|
30
30
|
"prepare": "yarn build",
|
|
31
|
+
"prepublishOnly": "yarn test && yarn build",
|
|
31
32
|
"release": "yarn build && changeset publish"
|
|
32
33
|
},
|
|
33
34
|
"repository": {
|
|
@@ -55,43 +56,43 @@
|
|
|
55
56
|
},
|
|
56
57
|
"homepage": "https://github.com/focus-trap/focus-trap-react#readme",
|
|
57
58
|
"devDependencies": {
|
|
58
|
-
"@babel/cli": "^7.17.
|
|
59
|
-
"@babel/core": "^7.17.
|
|
59
|
+
"@babel/cli": "^7.17.6",
|
|
60
|
+
"@babel/core": "^7.17.9",
|
|
60
61
|
"@babel/eslint-parser": "^7.17.0",
|
|
61
62
|
"@babel/plugin-proposal-class-properties": "^7.16.5",
|
|
62
63
|
"@babel/preset-env": "^7.16.11",
|
|
63
64
|
"@babel/preset-react": "^7.16.7",
|
|
64
|
-
"@changesets/cli": "^2.
|
|
65
|
+
"@changesets/cli": "^2.22.0",
|
|
65
66
|
"@testing-library/cypress": "^8.0.2",
|
|
66
|
-
"@testing-library/dom": "^8.
|
|
67
|
-
"@testing-library/jest-dom": "^5.16.
|
|
68
|
-
"@testing-library/react": "^
|
|
69
|
-
"@testing-library/user-event": "^
|
|
70
|
-
"@types/jquery": "^3.5.
|
|
67
|
+
"@testing-library/dom": "^8.13.0",
|
|
68
|
+
"@testing-library/jest-dom": "^5.16.4",
|
|
69
|
+
"@testing-library/react": "^13.1.1",
|
|
70
|
+
"@testing-library/user-event": "^14.1.1",
|
|
71
|
+
"@types/jquery": "^3.5.14",
|
|
71
72
|
"all-contributors-cli": "^6.20.0",
|
|
72
73
|
"babel-jest": "^27.5.1",
|
|
73
74
|
"babelify": "^10.0.0",
|
|
74
75
|
"browserify": "^17.0.0",
|
|
75
|
-
"budo": "^11.
|
|
76
|
-
"cypress": "^9.4
|
|
76
|
+
"budo": "^11.7.0",
|
|
77
|
+
"cypress": "^9.5.4",
|
|
77
78
|
"cypress-plugin-tab": "^1.0.5",
|
|
78
|
-
"eslint": "^8.
|
|
79
|
-
"eslint-config-prettier": "^8.
|
|
79
|
+
"eslint": "^8.13.0",
|
|
80
|
+
"eslint-config-prettier": "^8.5.0",
|
|
80
81
|
"eslint-plugin-cypress": "^2.12.1",
|
|
81
|
-
"eslint-plugin-react": "^7.
|
|
82
|
+
"eslint-plugin-react": "^7.29.4",
|
|
82
83
|
"jest": "^27.5.1",
|
|
83
84
|
"jest-watch-typeahead": "^1.0.0",
|
|
84
85
|
"onchange": "^7.1.0",
|
|
85
|
-
"prettier": "^2.
|
|
86
|
+
"prettier": "^2.6.2",
|
|
86
87
|
"prop-types": "^15.8.1",
|
|
87
|
-
"react": "^
|
|
88
|
-
"react-dom": "^
|
|
88
|
+
"react": "^18.0.0",
|
|
89
|
+
"react-dom": "^18.0.0",
|
|
89
90
|
"regenerator-runtime": "^0.13.9",
|
|
90
91
|
"start-server-and-test": "^1.14.0",
|
|
91
|
-
"typescript": "^4.
|
|
92
|
+
"typescript": "^4.6.3"
|
|
92
93
|
},
|
|
93
94
|
"dependencies": {
|
|
94
|
-
"focus-trap": "^6.
|
|
95
|
+
"focus-trap": "^6.8.1"
|
|
95
96
|
},
|
|
96
97
|
"peerDependencies": {
|
|
97
98
|
"prop-types": "^15.8.1",
|
package/src/focus-trap-react.js
CHANGED
|
@@ -311,6 +311,10 @@ FocusTrap.propTypes = {
|
|
|
311
311
|
]),
|
|
312
312
|
allowOutsideClick: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
|
|
313
313
|
preventScroll: PropTypes.bool,
|
|
314
|
+
tabbableOptions: PropTypes.shape({
|
|
315
|
+
displayCheck: PropTypes.oneOf(['full', 'non-zero-area', 'none']),
|
|
316
|
+
getShadowRoot: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
|
|
317
|
+
}),
|
|
314
318
|
}),
|
|
315
319
|
containerElements: PropTypes.arrayOf(PropTypes.instanceOf(ElementType)),
|
|
316
320
|
children: PropTypes.oneOfType([
|