focus-trap 7.6.2 β†’ 7.6.3

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 7.6.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 0a9b746: Prevent a previous focus trap that is manually paused from being automatically unpaused when the current trap is deactivated. Also prevent a paused trap that is not at the top of the stack from being unpaused.
8
+
3
9
  ## 7.6.2
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # focus-trap [![CI](https://github.com/focus-trap/focus-trap/workflows/CI/badge.svg?branch=master&event=push)](https://github.com/focus-trap/focus-trap/actions?query=workflow:CI+branch:master) [![license](https://badgen.now.sh/badge/license/MIT)](./LICENSE)
2
2
 
3
3
  <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
4
- [![All Contributors](https://img.shields.io/badge/all_contributors-34-orange.svg?style=flat-square)](#contributors)
4
+ [![All Contributors](https://img.shields.io/badge/all_contributors-35-orange.svg?style=flat-square)](#contributors)
5
5
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
6
6
 
7
7
  Trap focus within a DOM node.
@@ -379,40 +379,41 @@ In alphabetical order:
379
379
  <tr>
380
380
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/andersthorsen"><img src="https://avatars.githubusercontent.com/u/190081?v=4?s=100" width="100px;" alt="Anders Thorsen"/><br /><sub><b>Anders Thorsen</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Aandersthorsen" title="Bug reports">πŸ›</a></td>
381
381
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/bparish628"><img src="https://avatars1.githubusercontent.com/u/8492971?v=4?s=100" width="100px;" alt="Benjamin Parish"/><br /><sub><b>Benjamin Parish</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Abparish628" title="Bug reports">πŸ›</a></td>
382
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/bernhardoj"><img src="https://avatars.githubusercontent.com/u/50919443?v=4?s=100" width="100px;" alt="Bernhard Owen Josephus"/><br /><sub><b>Bernhard Owen Josephus</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=bernhardoj" title="Code">πŸ’»</a></td>
382
383
  <td align="center" valign="top" width="14.28%"><a href="https://clintgoodman.com"><img src="https://avatars3.githubusercontent.com/u/5473697?v=4?s=100" width="100px;" alt="Clint Goodman"/><br /><sub><b>Clint Goodman</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=cgood92" title="Code">πŸ’»</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=cgood92" title="Documentation">πŸ“–</a> <a href="#example-cgood92" title="Examples">πŸ’‘</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=cgood92" title="Tests">⚠️</a></td>
383
384
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/Dan503"><img src="https://avatars.githubusercontent.com/u/10610368?v=4?s=100" width="100px;" alt="Daniel Tonon"/><br /><sub><b>Daniel Tonon</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=Dan503" title="Documentation">πŸ“–</a> <a href="#tool-Dan503" title="Tools">πŸ”§</a> <a href="#a11y-Dan503" title="Accessibility">️️️️♿️</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=Dan503" title="Code">πŸ’»</a></td>
384
385
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/DaviDevMod"><img src="https://avatars.githubusercontent.com/u/98312056?v=4?s=100" width="100px;" alt="DaviDevMod"/><br /><sub><b>DaviDevMod</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=DaviDevMod" title="Documentation">πŸ“–</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=DaviDevMod" title="Code">πŸ’»</a> <a href="https://github.com/focus-trap/focus-trap/issues?q=author%3ADaviDevMod" title="Bug reports">πŸ›</a></td>
385
386
  <td align="center" valign="top" width="14.28%"><a href="http://davidtheclark.com/"><img src="https://avatars2.githubusercontent.com/u/628431?v=4?s=100" width="100px;" alt="David Clark"/><br /><sub><b>David Clark</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=davidtheclark" title="Code">πŸ’»</a> <a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Adavidtheclark" title="Bug reports">πŸ›</a> <a href="#infra-davidtheclark" title="Infrastructure (Hosting, Build-Tools, etc)">πŸš‡</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=davidtheclark" title="Tests">⚠️</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=davidtheclark" title="Documentation">πŸ“–</a> <a href="#maintenance-davidtheclark" title="Maintenance">🚧</a></td>
386
- <td align="center" valign="top" width="14.28%"><a href="https://github.com/features/security"><img src="https://avatars1.githubusercontent.com/u/27347476?v=4?s=100" width="100px;" alt="Dependabot"/><br /><sub><b>Dependabot</b></sub></a><br /><a href="#maintenance-dependabot" title="Maintenance">🚧</a></td>
387
387
  </tr>
388
388
  <tr>
389
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/features/security"><img src="https://avatars1.githubusercontent.com/u/27347476?v=4?s=100" width="100px;" alt="Dependabot"/><br /><sub><b>Dependabot</b></sub></a><br /><a href="#maintenance-dependabot" title="Maintenance">🚧</a></td>
389
390
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/jcfranco"><img src="https://avatars.githubusercontent.com/u/197440?v=4?s=100" width="100px;" alt="JC Franco"/><br /><sub><b>JC Franco</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=jcfranco" title="Code">πŸ’»</a></td>
390
391
  <td align="center" valign="top" width="14.28%"><a href="https://www.schilljs.com/"><img src="https://avatars.githubusercontent.com/u/213943?v=4?s=100" width="100px;" alt="Joas Schilling"/><br /><sub><b>Joas Schilling</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/pulls?q=is%3Apr+reviewed-by%3Anickvergessen" title="Reviewed Pull Requests">πŸ‘€</a></td>
391
392
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/skjnldsv"><img src="https://avatars.githubusercontent.com/u/14975046?v=4?s=100" width="100px;" alt="John MolakvoΓ¦"/><br /><sub><b>John MolakvoΓ¦</b></sub></a><br /><a href="#ideas-skjnldsv" title="Ideas, Planning, & Feedback">πŸ€”</a></td>
392
393
  <td align="center" valign="top" width="14.28%"><a href="http://reload.dk"><img src="https://avatars.githubusercontent.com/u/73966?v=4?s=100" width="100px;" alt="Kasper GarnΓ¦s"/><br /><sub><b>Kasper GarnΓ¦s</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=kasperg" title="Documentation">πŸ“–</a> <a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Akasperg" title="Bug reports">πŸ›</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=kasperg" title="Code">πŸ’»</a></td>
393
394
  <td align="center" valign="top" width="14.28%"><a href="http://blogs.esri.com/esri/arcgis/"><img src="https://avatars.githubusercontent.com/u/1231455?v=4?s=100" width="100px;" alt="Matt Driscoll"/><br /><sub><b>Matt Driscoll</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Adriskull" title="Bug reports">πŸ›</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=driskull" title="Code">πŸ’»</a> <a href="#tutorial-driskull" title="Tutorials">βœ…</a></td>
394
395
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/msev"><img src="https://avatars.githubusercontent.com/u/1529562?v=4?s=100" width="100px;" alt="Maxime"/><br /><sub><b>Maxime</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Amsev" title="Bug reports">πŸ›</a></td>
395
- <td align="center" valign="top" width="14.28%"><a href="https://github.com/michael-ar"><img src="https://avatars3.githubusercontent.com/u/18557997?v=4?s=100" width="100px;" alt="Michael Reynolds"/><br /><sub><b>Michael Reynolds</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Amichael-ar" title="Bug reports">πŸ›</a></td>
396
396
  </tr>
397
397
  <tr>
398
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/michael-ar"><img src="https://avatars3.githubusercontent.com/u/18557997?v=4?s=100" width="100px;" alt="Michael Reynolds"/><br /><sub><b>Michael Reynolds</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Amichael-ar" title="Bug reports">πŸ›</a></td>
398
399
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/liunate"><img src="https://avatars2.githubusercontent.com/u/38996291?v=4?s=100" width="100px;" alt="Nate Liu"/><br /><sub><b>Nate Liu</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=liunate" title="Tests">⚠️</a></td>
399
400
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/far-fetched"><img src="https://avatars.githubusercontent.com/u/11621383?v=4?s=100" width="100px;" alt="Piotr Panek"/><br /><sub><b>Piotr Panek</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Afar-fetched" title="Bug reports">πŸ›</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=far-fetched" title="Documentation">πŸ“–</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=far-fetched" title="Code">πŸ’»</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=far-fetched" title="Tests">⚠️</a></td>
400
401
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/randypuro"><img src="https://avatars2.githubusercontent.com/u/2579?v=4?s=100" width="100px;" alt="Randy Puro"/><br /><sub><b>Randy Puro</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Arandypuro" title="Bug reports">πŸ›</a></td>
401
402
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/sadick254"><img src="https://avatars2.githubusercontent.com/u/5238135?v=4?s=100" width="100px;" alt="Sadick"/><br /><sub><b>Sadick</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=sadick254" title="Code">πŸ’»</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=sadick254" title="Tests">⚠️</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=sadick254" title="Documentation">πŸ“–</a></td>
402
403
  <td align="center" valign="top" width="14.28%"><a href="https://scottblinch.me/"><img src="https://avatars2.githubusercontent.com/u/4682114?v=4?s=100" width="100px;" alt="Scott Blinch"/><br /><sub><b>Scott Blinch</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=scottblinch" title="Documentation">πŸ“–</a></td>
403
404
  <td align="center" valign="top" width="14.28%"><a href="https://seanmcp.com/"><img src="https://avatars1.githubusercontent.com/u/6360367?v=4?s=100" width="100px;" alt="Sean McPherson"/><br /><sub><b>Sean McPherson</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=SeanMcP" title="Code">πŸ’»</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=SeanMcP" title="Documentation">πŸ“–</a></td>
404
- <td align="center" valign="top" width="14.28%"><a href="https://github.com/skriems"><img src="https://avatars.githubusercontent.com/u/15573317?v=4?s=100" width="100px;" alt="Sebastian Kriems"/><br /><sub><b>Sebastian Kriems</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Askriems" title="Bug reports">πŸ›</a></td>
405
405
  </tr>
406
406
  <tr>
407
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/skriems"><img src="https://avatars.githubusercontent.com/u/15573317?v=4?s=100" width="100px;" alt="Sebastian Kriems"/><br /><sub><b>Sebastian Kriems</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Askriems" title="Bug reports">πŸ›</a></td>
407
408
  <td align="center" valign="top" width="14.28%"><a href="https://recollectr.io"><img src="https://avatars2.githubusercontent.com/u/6835891?v=4?s=100" width="100px;" alt="Slapbox"/><br /><sub><b>Slapbox</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3ASlapbox" title="Bug reports">πŸ›</a></td>
408
409
  <td align="center" valign="top" width="14.28%"><a href="https://stefancameron.com/"><img src="https://avatars3.githubusercontent.com/u/2855350?v=4?s=100" width="100px;" alt="Stefan Cameron"/><br /><sub><b>Stefan Cameron</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=stefcameron" title="Code">πŸ’»</a> <a href="https://github.com/focus-trap/focus-trap/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/commits?author=stefcameron" title="Tests">⚠️</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=stefcameron" title="Documentation">πŸ“–</a> <a href="#maintenance-stefcameron" title="Maintenance">🚧</a></td>
409
410
  <td align="center" valign="top" width="14.28%"><a href="http://tylerhawkins.info/201R/"><img src="https://avatars0.githubusercontent.com/u/13806458?v=4?s=100" width="100px;" alt="Tyler Hawkins"/><br /><sub><b>Tyler Hawkins</b></sub></a><br /><a href="#tool-thawkin3" title="Tools">πŸ”§</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=thawkin3" title="Tests">⚠️</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=thawkin3" title="Documentation">πŸ“–</a></td>
410
411
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/vasiliki-b"><img src="https://avatars.githubusercontent.com/u/98032598?v=4?s=100" width="100px;" alt="Vasiliki Boutas"/><br /><sub><b>Vasiliki Boutas</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Avasiliki-b" title="Bug reports">πŸ›</a></td>
411
412
  <td align="center" valign="top" width="14.28%"><a href="https://vinicius73.dev/"><img src="https://avatars.githubusercontent.com/u/1561347?v=4?s=100" width="100px;" alt="Vinicius Reis"/><br /><sub><b>Vinicius Reis</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=vinicius73" title="Code">πŸ’»</a> <a href="#ideas-vinicius73" title="Ideas, Planning, & Feedback">πŸ€”</a></td>
412
413
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/wandroll"><img src="https://avatars.githubusercontent.com/u/4492317?v=4?s=100" width="100px;" alt="Wandrille Verlut"/><br /><sub><b>Wandrille Verlut</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=wandroll" title="Code">πŸ’»</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=wandroll" title="Tests">⚠️</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=wandroll" title="Documentation">πŸ“–</a> <a href="#tool-wandroll" title="Tools">πŸ”§</a></td>
413
- <td align="center" valign="top" width="14.28%"><a href="http://willmruzek.com/"><img src="https://avatars.githubusercontent.com/u/108522?v=4?s=100" width="100px;" alt="Will Mruzek"/><br /><sub><b>Will Mruzek</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=mruzekw" title="Code">πŸ’»</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=mruzekw" title="Documentation">πŸ“–</a> <a href="#example-mruzekw" title="Examples">πŸ’‘</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=mruzekw" title="Tests">⚠️</a> <a href="#question-mruzekw" title="Answering Questions">πŸ’¬</a></td>
414
414
  </tr>
415
415
  <tr>
416
+ <td align="center" valign="top" width="14.28%"><a href="http://willmruzek.com/"><img src="https://avatars.githubusercontent.com/u/108522?v=4?s=100" width="100px;" alt="Will Mruzek"/><br /><sub><b>Will Mruzek</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=mruzekw" title="Code">πŸ’»</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=mruzekw" title="Documentation">πŸ“–</a> <a href="#example-mruzekw" title="Examples">πŸ’‘</a> <a href="https://github.com/focus-trap/focus-trap/commits?author=mruzekw" title="Tests">⚠️</a> <a href="#question-mruzekw" title="Answering Questions">πŸ’¬</a></td>
416
417
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/zioth"><img src="https://avatars3.githubusercontent.com/u/945603?v=4?s=100" width="100px;" alt="Zioth"/><br /><sub><b>Zioth</b></sub></a><br /><a href="#ideas-zioth" title="Ideas, Planning, & Feedback">πŸ€”</a> <a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Azioth" title="Bug reports">πŸ›</a></td>
417
418
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/glushkova91"><img src="https://avatars.githubusercontent.com/u/13402897?v=4?s=100" width="100px;" alt="glushkova91"/><br /><sub><b>glushkova91</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/commits?author=glushkova91" title="Documentation">πŸ“–</a></td>
418
419
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/jpveooys"><img src="https://avatars.githubusercontent.com/u/66470099?v=4?s=100" width="100px;" alt="jpveooys"/><br /><sub><b>jpveooys</b></sub></a><br /><a href="https://github.com/focus-trap/focus-trap/issues?q=author%3Ajpveooys" title="Bug reports">πŸ›</a></td>
@@ -1,8 +1,8 @@
1
1
  /*!
2
- * focus-trap 7.6.2
2
+ * focus-trap 7.6.3
3
3
  * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
4
4
  */
5
- import { isFocusable, tabbable, focusable, isTabbable, getTabIndex } from 'tabbable';
5
+ import { tabbable, focusable, isTabbable, getTabIndex, isFocusable } from 'tabbable';
6
6
 
7
7
  function _arrayLikeToArray(r, a) {
8
8
  (null == a || a > r.length) && (a = r.length);
@@ -15,9 +15,9 @@ function _arrayWithoutHoles(r) {
15
15
  function _defineProperty(e, r, t) {
16
16
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
17
17
  value: t,
18
- enumerable: !0,
19
- configurable: !0,
20
- writable: !0
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true
21
21
  }) : e[r] = t, e;
22
22
  }
23
23
  function _iterableToArray(r) {
@@ -39,7 +39,7 @@ function ownKeys(e, r) {
39
39
  function _objectSpread2(e) {
40
40
  for (var r = 1; r < arguments.length; r++) {
41
41
  var t = null != arguments[r] ? arguments[r] : {};
42
- r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
42
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
43
43
  _defineProperty(e, r, t[r]);
44
44
  }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
45
45
  Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
@@ -53,7 +53,7 @@ function _toConsumableArray(r) {
53
53
  function _toPrimitive(t, r) {
54
54
  if ("object" != typeof t || !t) return t;
55
55
  var e = t[Symbol.toPrimitive];
56
- if (void 0 !== e) {
56
+ if (undefined !== e) {
57
57
  var i = e.call(t, r || "default");
58
58
  if ("object" != typeof i) return i;
59
59
  throw new TypeError("@@toPrimitive must return a primitive value.");
@@ -68,7 +68,7 @@ function _unsupportedIterableToArray(r, a) {
68
68
  if (r) {
69
69
  if ("string" == typeof r) return _arrayLikeToArray(r, a);
70
70
  var t = {}.toString.call(r).slice(8, -1);
71
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
71
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : undefined;
72
72
  }
73
73
  }
74
74
 
@@ -77,7 +77,7 @@ var activeFocusTraps = {
77
77
  if (trapStack.length > 0) {
78
78
  var activeTrap = trapStack[trapStack.length - 1];
79
79
  if (activeTrap !== trap) {
80
- activeTrap.pause();
80
+ activeTrap._setPausedState(true);
81
81
  }
82
82
  }
83
83
  var trapIndex = trapStack.indexOf(trap);
@@ -94,8 +94,8 @@ var activeFocusTraps = {
94
94
  if (trapIndex !== -1) {
95
95
  trapStack.splice(trapIndex, 1);
96
96
  }
97
- if (trapStack.length > 0) {
98
- trapStack[trapStack.length - 1].unpause();
97
+ if (trapStack.length > 0 && !trapStack[trapStack.length - 1]._isManuallyPaused()) {
98
+ trapStack[trapStack.length - 1]._setPausedState(false);
99
99
  }
100
100
  }
101
101
  };
@@ -103,10 +103,10 @@ var isSelectableInput = function isSelectableInput(node) {
103
103
  return node.tagName && node.tagName.toLowerCase() === 'input' && typeof node.select === 'function';
104
104
  };
105
105
  var isEscapeEvent = function isEscapeEvent(e) {
106
- return (e === null || e === void 0 ? void 0 : e.key) === 'Escape' || (e === null || e === void 0 ? void 0 : e.key) === 'Esc' || (e === null || e === void 0 ? void 0 : e.keyCode) === 27;
106
+ return (e === null || e === undefined ? undefined : e.key) === 'Escape' || (e === null || e === undefined ? undefined : e.key) === 'Esc' || (e === null || e === undefined ? undefined : e.keyCode) === 27;
107
107
  };
108
108
  var isTabEvent = function isTabEvent(e) {
109
- return (e === null || e === void 0 ? void 0 : e.key) === 'Tab' || (e === null || e === void 0 ? void 0 : e.keyCode) === 9;
109
+ return (e === null || e === undefined ? undefined : e.key) === 'Tab' || (e === null || e === undefined ? undefined : e.keyCode) === 9;
110
110
  };
111
111
 
112
112
  // checks for TAB by default
@@ -133,7 +133,7 @@ var valueOrHandler = function valueOrHandler(value) {
133
133
  for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
134
134
  params[_key - 1] = arguments[_key];
135
135
  }
136
- return typeof value === 'function' ? value.apply(void 0, params) : value;
136
+ return typeof value === 'function' ? value.apply(undefined, params) : value;
137
137
  };
138
138
  var getActualTarget = function getActualTarget(event) {
139
139
  // NOTE: If the trap is _inside_ a shadow DOM, event.target will always be the
@@ -152,8 +152,8 @@ var internalTrapStack = [];
152
152
  var createFocusTrap = function createFocusTrap(elements, userOptions) {
153
153
  // SSR: a live trap shouldn't be created in this type of environment so this
154
154
  // should be safe code to execute if the `document` option isn't specified
155
- var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
156
- var trapStack = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.trapStack) || internalTrapStack;
155
+ var doc = (userOptions === null || userOptions === undefined ? undefined : userOptions.document) || document;
156
+ var trapStack = (userOptions === null || userOptions === undefined ? undefined : userOptions.trapStack) || internalTrapStack;
157
157
  var config = _objectSpread2({
158
158
  returnFocusOnDeactivate: true,
159
159
  escapeDeactivates: true,
@@ -193,6 +193,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
193
193
  mostRecentlyFocusedNode: null,
194
194
  active: false,
195
195
  paused: false,
196
+ manuallyPaused: false,
196
197
  // timer ID for when delayInitialFocus is true and initial focus in this trap
197
198
  // has been delayed during activation
198
199
  delayInitialFocusTimer: undefined,
@@ -224,7 +225,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
224
225
  * if the element isn't found.
225
226
  */
226
227
  var findContainerIndex = function findContainerIndex(element, event) {
227
- var composedPath = typeof (event === null || event === void 0 ? void 0 : event.composedPath) === 'function' ? event.composedPath() : undefined;
228
+ var composedPath = typeof (event === null || event === undefined ? undefined : event.composedPath) === 'function' ? event.composedPath() : undefined;
228
229
  // NOTE: search `containerGroups` because it's possible a group contains no tabbable
229
230
  // nodes, but still contains focusable nodes (e.g. if they all have `tabindex=-1`)
230
231
  // and we still need to find the element in there
@@ -235,7 +236,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
235
236
  // web components if the `tabbableOptions.getShadowRoot` option was used for
236
237
  // the trap, enabling shadow DOM support in tabbable (`Node.contains()` doesn't
237
238
  // look inside web components even if open)
238
- composedPath === null || composedPath === void 0 ? void 0 : composedPath.includes(container)) || tabbableNodes.find(function (node) {
239
+ composedPath === null || composedPath === undefined ? undefined : composedPath.includes(container)) || tabbableNodes.find(function (node) {
239
240
  return node === element;
240
241
  });
241
242
  });
@@ -262,12 +263,12 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
262
263
  var getNodeForOption = function getNodeForOption(optionName) {
263
264
  var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
264
265
  _ref2$hasFallback = _ref2.hasFallback,
265
- hasFallback = _ref2$hasFallback === void 0 ? false : _ref2$hasFallback,
266
+ hasFallback = _ref2$hasFallback === undefined ? false : _ref2$hasFallback,
266
267
  _ref2$params = _ref2.params,
267
- params = _ref2$params === void 0 ? [] : _ref2$params;
268
+ params = _ref2$params === undefined ? [] : _ref2$params;
268
269
  var optionValue = config[optionName];
269
270
  if (typeof optionValue === 'function') {
270
- optionValue = optionValue.apply(void 0, _toConsumableArray(params));
271
+ optionValue = optionValue.apply(undefined, _toConsumableArray(params));
271
272
  }
272
273
  if (optionValue === true) {
273
274
  optionValue = undefined; // use default value
@@ -483,7 +484,7 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
483
484
  var target = _ref3.target,
484
485
  event = _ref3.event,
485
486
  _ref3$isBackward = _ref3.isBackward,
486
- isBackward = _ref3$isBackward === void 0 ? false : _ref3$isBackward;
487
+ isBackward = _ref3$isBackward === undefined ? false : _ref3$isBackward;
487
488
  target = target || getActualTarget(event);
488
489
  updateTabbableNodes();
489
490
  var destinationNode = null;
@@ -865,14 +866,14 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
865
866
  state.active = true;
866
867
  state.paused = false;
867
868
  state.nodeFocusedBeforeActivation = doc.activeElement;
868
- onActivate === null || onActivate === void 0 || onActivate();
869
+ onActivate === null || onActivate === undefined || onActivate();
869
870
  var finishActivation = function finishActivation() {
870
871
  if (checkCanFocusTrap) {
871
872
  updateTabbableNodes();
872
873
  }
873
874
  addListeners();
874
875
  updateObservedNodes();
875
- onPostActivate === null || onPostActivate === void 0 || onPostActivate();
876
+ onPostActivate === null || onPostActivate === undefined || onPostActivate();
876
877
  };
877
878
  if (checkCanFocusTrap) {
878
879
  checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
@@ -901,13 +902,13 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
901
902
  var onPostDeactivate = getOption(options, 'onPostDeactivate');
902
903
  var checkCanReturnFocus = getOption(options, 'checkCanReturnFocus');
903
904
  var returnFocus = getOption(options, 'returnFocus', 'returnFocusOnDeactivate');
904
- onDeactivate === null || onDeactivate === void 0 || onDeactivate();
905
+ onDeactivate === null || onDeactivate === undefined || onDeactivate();
905
906
  var finishDeactivation = function finishDeactivation() {
906
907
  delay(function () {
907
908
  if (returnFocus) {
908
909
  _tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
909
910
  }
910
- onPostDeactivate === null || onPostDeactivate === void 0 || onPostDeactivate();
911
+ onPostDeactivate === null || onPostDeactivate === undefined || onPostDeactivate();
911
912
  });
912
913
  };
913
914
  if (returnFocus && checkCanReturnFocus) {
@@ -918,31 +919,21 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
918
919
  return this;
919
920
  },
920
921
  pause: function pause(pauseOptions) {
921
- if (state.paused || !state.active) {
922
+ if (!state.active) {
922
923
  return this;
923
924
  }
924
- var onPause = getOption(pauseOptions, 'onPause');
925
- var onPostPause = getOption(pauseOptions, 'onPostPause');
926
- state.paused = true;
927
- onPause === null || onPause === void 0 || onPause();
928
- removeListeners();
929
- updateObservedNodes();
930
- onPostPause === null || onPostPause === void 0 || onPostPause();
931
- return this;
925
+ state.manuallyPaused = true;
926
+ return this._setPausedState(true, pauseOptions);
932
927
  },
933
928
  unpause: function unpause(unpauseOptions) {
934
- if (!state.paused || !state.active) {
929
+ if (!state.active) {
935
930
  return this;
936
931
  }
937
- var onUnpause = getOption(unpauseOptions, 'onUnpause');
938
- var onPostUnpause = getOption(unpauseOptions, 'onPostUnpause');
939
- state.paused = false;
940
- onUnpause === null || onUnpause === void 0 || onUnpause();
941
- updateTabbableNodes();
942
- addListeners();
943
- updateObservedNodes();
944
- onPostUnpause === null || onPostUnpause === void 0 || onPostUnpause();
945
- return this;
932
+ state.manuallyPaused = false;
933
+ if (trapStack[trapStack.length - 1] !== this) {
934
+ return this;
935
+ }
936
+ return this._setPausedState(false, unpauseOptions);
946
937
  },
947
938
  updateContainerElements: function updateContainerElements(containerElements) {
948
939
  var elementsAsArray = [].concat(containerElements).filter(Boolean);
@@ -956,6 +947,38 @@ var createFocusTrap = function createFocusTrap(elements, userOptions) {
956
947
  return this;
957
948
  }
958
949
  };
950
+ Object.defineProperties(trap, {
951
+ _isManuallyPaused: {
952
+ value: function value() {
953
+ return state.manuallyPaused;
954
+ }
955
+ },
956
+ _setPausedState: {
957
+ value: function value(paused, options) {
958
+ if (state.paused === paused) {
959
+ return this;
960
+ }
961
+ state.paused = paused;
962
+ if (paused) {
963
+ var onPause = getOption(options, 'onPause');
964
+ var onPostPause = getOption(options, 'onPostPause');
965
+ onPause === null || onPause === undefined || onPause();
966
+ removeListeners();
967
+ updateObservedNodes();
968
+ onPostPause === null || onPostPause === undefined || onPostPause();
969
+ } else {
970
+ var onUnpause = getOption(options, 'onUnpause');
971
+ var onPostUnpause = getOption(options, 'onPostUnpause');
972
+ onUnpause === null || onUnpause === undefined || onUnpause();
973
+ updateTabbableNodes();
974
+ addListeners();
975
+ updateObservedNodes();
976
+ onPostUnpause === null || onPostUnpause === undefined || onPostUnpause();
977
+ }
978
+ return this;
979
+ }
980
+ }
981
+ });
959
982
 
960
983
  // initialize container elements
961
984
  trap.updateContainerElements(elements);