focus-lock
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -44,4 +44,2 @@ import { correctNodes } from './utils/correctFocus'; | ||
var correctedIndexDiff = correctedIndex - (lastNode ? correctedNodes.indexOf(lastNode) : activeIndex); | ||
var returnFirstNode = pickFocusable(innerNodes, innerTabbables[0]); | ||
var returnLastNode = pickFocusable(innerNodes, innerTabbables[innerTabbables.length - 1]); | ||
// old focus | ||
@@ -51,2 +49,11 @@ if (!indexDiff && lastNodeInside >= 0) { | ||
} | ||
// no tabbable elements, autofocus is not possible | ||
if (innerTabbables.length === 0) { | ||
// an edge case with no tabbable elements | ||
// return the last focusable one | ||
// with some probability this will prevent focus from cycling across the lock, but there is no tabbale elements to cycle to | ||
return lastNodeInside; | ||
} | ||
var returnFirstNode = pickFocusable(innerNodes, innerTabbables[0]); | ||
var returnLastNode = pickFocusable(innerNodes, innerTabbables[innerTabbables.length - 1]); | ||
// first element | ||
@@ -53,0 +60,0 @@ if (activeIndex <= firstNodeIndex && isOnGuard && Math.abs(indexDiff) > 1) { |
@@ -44,4 +44,2 @@ import { correctNodes } from './utils/correctFocus'; | ||
const correctedIndexDiff = correctedIndex - (lastNode ? correctedNodes.indexOf(lastNode) : activeIndex); | ||
const returnFirstNode = pickFocusable(innerNodes, innerTabbables[0]); | ||
const returnLastNode = pickFocusable(innerNodes, innerTabbables[innerTabbables.length - 1]); | ||
// old focus | ||
@@ -51,2 +49,11 @@ if (!indexDiff && lastNodeInside >= 0) { | ||
} | ||
// no tabbable elements, autofocus is not possible | ||
if (innerTabbables.length === 0) { | ||
// an edge case with no tabbable elements | ||
// return the last focusable one | ||
// with some probability this will prevent focus from cycling across the lock, but there is no tabbale elements to cycle to | ||
return lastNodeInside; | ||
} | ||
const returnFirstNode = pickFocusable(innerNodes, innerTabbables[0]); | ||
const returnLastNode = pickFocusable(innerNodes, innerTabbables[innerTabbables.length - 1]); | ||
// first element | ||
@@ -53,0 +60,0 @@ if (activeIndex <= firstNodeIndex && isOnGuard && Math.abs(indexDiff) > 1) { |
@@ -47,4 +47,2 @@ "use strict"; | ||
var correctedIndexDiff = correctedIndex - (lastNode ? correctedNodes.indexOf(lastNode) : activeIndex); | ||
var returnFirstNode = (0, firstFocus_1.pickFocusable)(innerNodes, innerTabbables[0]); | ||
var returnLastNode = (0, firstFocus_1.pickFocusable)(innerNodes, innerTabbables[innerTabbables.length - 1]); | ||
// old focus | ||
@@ -54,2 +52,11 @@ if (!indexDiff && lastNodeInside >= 0) { | ||
} | ||
// no tabbable elements, autofocus is not possible | ||
if (innerTabbables.length === 0) { | ||
// an edge case with no tabbable elements | ||
// return the last focusable one | ||
// with some probability this will prevent focus from cycling across the lock, but there is no tabbale elements to cycle to | ||
return lastNodeInside; | ||
} | ||
var returnFirstNode = (0, firstFocus_1.pickFocusable)(innerNodes, innerTabbables[0]); | ||
var returnLastNode = (0, firstFocus_1.pickFocusable)(innerNodes, innerTabbables[innerTabbables.length - 1]); | ||
// first element | ||
@@ -56,0 +63,0 @@ if (activeIndex <= firstNodeIndex && isOnGuard && Math.abs(indexDiff) > 1) { |
{ | ||
"name": "focus-lock", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "DOM trap for a focus", | ||
@@ -5,0 +5,0 @@ "main": "dist/es5/index.js", |
184085
4386