focus-trap-react 8.11.3 → 9.0.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 +8 -0
- package/README.md +1 -1
- package/dist/focus-trap-react.js +5 -16
- package/package.json +3 -3
- package/src/focus-trap-react.js +4 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 9.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 4a77d87: Stop using the infamous `findDOMNode()` on provided `containerElements`.
|
|
8
|
+
- There seems to have been no good reason for this as this prop, if specified, is already required to be an array of HTMLElement references, which means these nodes have already been rendered (if they were once React elements). There appears to have been no remaining need for this API.
|
|
9
|
+
- Furthermore, the minimum supported version of React is now 16.3 as it technically has been for a while now since that is the version that introduced callback refs, which we've been using for quite some time now (so this bump will hopefully not cause any ripples).
|
|
10
|
+
|
|
3
11
|
## 8.11.3
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -220,7 +220,7 @@ In alphabetical order:
|
|
|
220
220
|
<tr>
|
|
221
221
|
<td align="center"><a href="https://scottrippey.github.io/"><img src="https://avatars3.githubusercontent.com/u/430608?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Scott Rippey</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=scottrippey" title="Code">💻</a> <a href="https://github.com/focus-trap/focus-trap-react/issues?q=author%3Ascottrippey" title="Bug reports">🐛</a></td>
|
|
222
222
|
<td align="center"><a href="https://seanmcp.com/"><img src="https://avatars1.githubusercontent.com/u/6360367?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sean McPherson</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=SeanMcP" title="Code">💻</a></td>
|
|
223
|
-
<td align="center"><a href="https://recollectr.io"><img src="https://avatars2.githubusercontent.com/u/6835891?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Slapbox</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=Slapbox" title="Documentation">📖</a></td>
|
|
223
|
+
<td align="center"><a href="https://recollectr.io"><img src="https://avatars2.githubusercontent.com/u/6835891?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Slapbox</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=Slapbox" title="Documentation">📖</a> <a href="https://github.com/focus-trap/focus-trap-react/issues?q=author%3ASlapbox" title="Bug reports">🐛</a></td>
|
|
224
224
|
<td align="center"><a href="https://stefancameron.com/"><img src="https://avatars3.githubusercontent.com/u/2855350?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stefan Cameron</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=stefcameron" title="Code">💻</a> <a href="https://github.com/focus-trap/focus-trap-react/issues?q=author%3Astefcameron" title="Bug reports">🐛</a> <a href="#infra-stefcameron" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=stefcameron" title="Tests">⚠️</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=stefcameron" title="Documentation">📖</a> <a href="#maintenance-stefcameron" title="Maintenance">🚧</a></td>
|
|
225
225
|
<td align="center"><a href="http://tylerhawkins.info/201R/"><img src="https://avatars0.githubusercontent.com/u/13806458?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler Hawkins</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=thawkin3" title="Documentation">📖</a> <a href="#example-thawkin3" title="Examples">💡</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=thawkin3" title="Tests">⚠️</a> <a href="#tool-thawkin3" title="Tools">🔧</a></td>
|
|
226
226
|
<td align="center"><a href="https://github.com/wandroll"><img src="https://avatars.githubusercontent.com/u/4492317?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Wandrille Verlut</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap-react/commits?author=wandroll" title="Code">💻</a> <a href="https://github.com/focus-trap/focus-trap-react/commits?author=wandroll" title="Tests">⚠️</a></td>
|
package/dist/focus-trap-react.js
CHANGED
|
@@ -26,20 +26,13 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
26
26
|
|
|
27
27
|
var React = require('react');
|
|
28
28
|
|
|
29
|
-
var ReactDOM = require('react-dom');
|
|
30
|
-
|
|
31
29
|
var PropTypes = require('prop-types');
|
|
32
30
|
|
|
33
31
|
var _require = require('focus-trap'),
|
|
34
32
|
createFocusTrap = _require.createFocusTrap;
|
|
35
33
|
|
|
36
34
|
var _require2 = require('tabbable'),
|
|
37
|
-
isFocusable = _require2.isFocusable;
|
|
38
|
-
// to fix in order to move the code forward to the next major version of React.
|
|
39
|
-
// @see https://github.com/davidtheclark/focus-trap-react/issues/77
|
|
40
|
-
|
|
41
|
-
/* eslint-disable react/no-find-dom-node */
|
|
42
|
-
|
|
35
|
+
isFocusable = _require2.isFocusable;
|
|
43
36
|
|
|
44
37
|
var FocusTrap = /*#__PURE__*/function (_React$Component) {
|
|
45
38
|
_inherits(FocusTrap, _React$Component);
|
|
@@ -307,15 +300,11 @@ var FocusTrap = /*#__PURE__*/function (_React$Component) {
|
|
|
307
300
|
key: "setupFocusTrap",
|
|
308
301
|
value: function setupFocusTrap() {
|
|
309
302
|
if (!this.focusTrap) {
|
|
310
|
-
var
|
|
311
|
-
// a new text node with the text wrapped in it instead of treating the
|
|
312
|
-
// string as a selector and resolving it to a node in the DOM
|
|
313
|
-
ReactDOM.findDOMNode);
|
|
314
|
-
var nodesExist = focusTrapElementDOMNodes.some(Boolean);
|
|
303
|
+
var nodesExist = this.focusTrapElements.some(Boolean);
|
|
315
304
|
|
|
316
305
|
if (nodesExist) {
|
|
317
306
|
// eslint-disable-next-line react/prop-types -- _createFocusTrap is an internal prop
|
|
318
|
-
this.focusTrap = this.props._createFocusTrap(
|
|
307
|
+
this.focusTrap = this.props._createFocusTrap(this.focusTrapElements, this.internalOptions);
|
|
319
308
|
|
|
320
309
|
if (this.props.active) {
|
|
321
310
|
this.focusTrap.activate();
|
|
@@ -404,7 +393,7 @@ var FocusTrap = /*#__PURE__*/function (_React$Component) {
|
|
|
404
393
|
throw new Error('A focus-trap cannot use a Fragment as its child container. Try replacing it with a <div> element.');
|
|
405
394
|
}
|
|
406
395
|
|
|
407
|
-
var
|
|
396
|
+
var callbackRef = function callbackRef(element) {
|
|
408
397
|
var containerElements = _this3.props.containerElements;
|
|
409
398
|
|
|
410
399
|
if (child) {
|
|
@@ -419,7 +408,7 @@ var FocusTrap = /*#__PURE__*/function (_React$Component) {
|
|
|
419
408
|
};
|
|
420
409
|
|
|
421
410
|
var childWithRef = React.cloneElement(child, {
|
|
422
|
-
ref:
|
|
411
|
+
ref: callbackRef
|
|
423
412
|
});
|
|
424
413
|
return childWithRef;
|
|
425
414
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "focus-trap-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "A React component that traps focus.",
|
|
5
5
|
"main": "dist/focus-trap-react.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
},
|
|
100
100
|
"peerDependencies": {
|
|
101
101
|
"prop-types": "^15.8.1",
|
|
102
|
-
"react": ">=16.
|
|
103
|
-
"react-dom": ">=16.
|
|
102
|
+
"react": ">=16.3.0",
|
|
103
|
+
"react-dom": ">=16.3.0"
|
|
104
104
|
}
|
|
105
105
|
}
|
package/src/focus-trap-react.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
const React = require('react');
|
|
2
|
-
const ReactDOM = require('react-dom');
|
|
3
2
|
const PropTypes = require('prop-types');
|
|
4
3
|
const { createFocusTrap } = require('focus-trap');
|
|
5
4
|
const { isFocusable } = require('tabbable');
|
|
6
5
|
|
|
7
|
-
// TODO: These issues are related to older React features which we'll likely need
|
|
8
|
-
// to fix in order to move the code forward to the next major version of React.
|
|
9
|
-
// @see https://github.com/davidtheclark/focus-trap-react/issues/77
|
|
10
|
-
/* eslint-disable react/no-find-dom-node */
|
|
11
|
-
|
|
12
6
|
class FocusTrap extends React.Component {
|
|
13
7
|
constructor(props) {
|
|
14
8
|
super(props);
|
|
@@ -277,18 +271,11 @@ class FocusTrap extends React.Component {
|
|
|
277
271
|
|
|
278
272
|
setupFocusTrap() {
|
|
279
273
|
if (!this.focusTrap) {
|
|
280
|
-
const
|
|
281
|
-
// NOTE: `findDOMNode()` does not support CSS selectors; it'll just return
|
|
282
|
-
// a new text node with the text wrapped in it instead of treating the
|
|
283
|
-
// string as a selector and resolving it to a node in the DOM
|
|
284
|
-
ReactDOM.findDOMNode
|
|
285
|
-
);
|
|
286
|
-
|
|
287
|
-
const nodesExist = focusTrapElementDOMNodes.some(Boolean);
|
|
274
|
+
const nodesExist = this.focusTrapElements.some(Boolean);
|
|
288
275
|
if (nodesExist) {
|
|
289
276
|
// eslint-disable-next-line react/prop-types -- _createFocusTrap is an internal prop
|
|
290
277
|
this.focusTrap = this.props._createFocusTrap(
|
|
291
|
-
|
|
278
|
+
this.focusTrapElements,
|
|
292
279
|
this.internalOptions
|
|
293
280
|
);
|
|
294
281
|
|
|
@@ -378,7 +365,7 @@ class FocusTrap extends React.Component {
|
|
|
378
365
|
);
|
|
379
366
|
}
|
|
380
367
|
|
|
381
|
-
const
|
|
368
|
+
const callbackRef = (element) => {
|
|
382
369
|
const { containerElements } = this.props;
|
|
383
370
|
|
|
384
371
|
if (child) {
|
|
@@ -395,7 +382,7 @@ class FocusTrap extends React.Component {
|
|
|
395
382
|
};
|
|
396
383
|
|
|
397
384
|
const childWithRef = React.cloneElement(child, {
|
|
398
|
-
ref:
|
|
385
|
+
ref: callbackRef,
|
|
399
386
|
});
|
|
400
387
|
|
|
401
388
|
return childWithRef;
|