vrembem 1.39.0 → 1.40.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.
@@ -1273,7 +1273,12 @@
1273
1273
  var index = obj.collection.findIndex(function (item) {
1274
1274
  return item.target === popover.target;
1275
1275
  });
1276
- obj.collection[index].state = 'hide'; // Return the popover
1276
+ obj.collection[index].state = 'hide'; // Clear the memory if popover trigger matches the ones saved in memory
1277
+
1278
+ if (popover.trigger === obj.memory.trigger) {
1279
+ obj.memory.trigger = null;
1280
+ } // Return the popover
1281
+
1277
1282
 
1278
1283
  return popover;
1279
1284
  }
@@ -1287,7 +1292,9 @@
1287
1292
  return obj.collection;
1288
1293
  }
1289
1294
  function hideCheck(popover, obj) {
1290
- // Needed to correctly check which element is currently being focused
1295
+ // Only run hideCheck if provided popover is currently open
1296
+ if (popover.state != 'show') return; // Needed to correctly check which element is currently being focused
1297
+
1291
1298
  setTimeout(function () {
1292
1299
  // Check if trigger or target are being hovered
1293
1300
  var isHovered = popover.target.closest(':hover') === popover.target || popover.trigger.closest(':hover') === popover.trigger; // Check if trigger or target are being focused
@@ -1457,13 +1464,31 @@
1457
1464
  if (popover.target.classList.contains(this.settings.stateActive)) {
1458
1465
  hide$2(popover, this);
1459
1466
  } else {
1467
+ this.memory.trigger = popover.trigger;
1460
1468
  show(popover, this);
1461
1469
  documentClick(popover, this);
1462
1470
  }
1463
1471
  }
1464
1472
  function handlerKeydown(event) {
1465
- if (event.key === 'Escape') {
1466
- hideAll(this);
1473
+ var _this = this;
1474
+
1475
+ switch (event.key) {
1476
+ case 'Escape':
1477
+ if (this.memory.trigger) {
1478
+ this.memory.trigger.focus();
1479
+ }
1480
+
1481
+ hideAll(this);
1482
+ return;
1483
+
1484
+ case 'Tab':
1485
+ this.collection.forEach(function (popover) {
1486
+ hideCheck(popover, _this);
1487
+ });
1488
+ return;
1489
+
1490
+ default:
1491
+ return;
1467
1492
  }
1468
1493
  }
1469
1494
  function documentClick(popover, obj) {
@@ -3431,6 +3456,9 @@
3431
3456
  this.defaults = defaults;
3432
3457
  this.settings = _extends({}, this.defaults, options);
3433
3458
  this.collection = [];
3459
+ this.memory = {
3460
+ trigger: null
3461
+ };
3434
3462
  this.__handlerKeydown = handlerKeydown.bind(this);
3435
3463
  if (this.settings.autoInit) this.init();
3436
3464
  }