From 16e90f52897f1aa46cae9a4a84332add35cd50da Mon Sep 17 00:00:00 2001 From: zombieFox Date: Fri, 14 Jun 2019 20:15:10 +0100 Subject: [PATCH] [bug] fix link focus on edit or remove --- css/link.css | 1 + js/link.js | 52 ++++++++++++++++++++++++++++++++------------------- js/version.js | 2 +- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/css/link.css b/css/link.css index 2ca55c76..f4df06d1 100755 --- a/css/link.css +++ b/css/link.css @@ -54,6 +54,7 @@ .link-item:hover { transform: scale(1.05); z-index: 2; + outline: 0; } .link-item:active { diff --git a/js/link.js b/js/link.js index be4217e9..6a1e5b36 100644 --- a/js/link.js +++ b/js/link.js @@ -4,8 +4,17 @@ var link = (function() { var _returnToPreviousFocusLink = function() { if (_previousFocusLink != null) { - helper.eA(".link-panel-back")[_previousFocusLink].querySelectorAll(".link-control-item")[0].focus(); - _previousFocusLink = null + var linkPanelFront = helper.eA(".link-panel-front"); + if (linkPanelFront.length > 0) { + if (_previousFocusLink >= 0) { + linkPanelFront[_previousFocusLink].focus(); + } else { + linkPanelFront[0].focus(); + }; + } else { + helper.e("body").focus(); + }; + _previousFocusLink = null; }; }; @@ -129,11 +138,26 @@ var link = (function() { }; var remove = function(bookmarkData) { - bookmarks.remove(bookmarkData); - _checkCount(); - data.save(); - clear(); - render.item.all(); + modal.render({ + heading: "Remove " + bookmarkData.name + " bookmark", + content: "Are you sure you want to remove this bookmark? This can not be undone.", + successAction: function() { + _previousFocusLink = _previousFocusLink - 1; + bookmarks.remove(bookmarkData); + _checkCount(); + data.save(); + clear(); + render.item.all(); + control.dependents(); + control.render(); + _returnToPreviousFocusLink(); + }, + cancelAction: function() { + _returnToPreviousFocusLink(); + }, + actionText: "Remove", + size: "small" + }); }; var _checkCount = function() { @@ -438,18 +462,8 @@ var link = (function() { edit(data); }, false); linkRemove.addEventListener("click", function() { - modal.render({ - heading: "Remove " + data.name + " bookmark", - content: "Are you sure you want to remove this bookmark? This can not be undone.", - successAction: function() { - remove(data); - control.dependents(); - control.render(); - }, - actionText: "Remove", - cancelText: "Cancel", - size: "small" - }); + _previousFocusLink = index; + remove(data); }, false); return linkItem; diff --git a/js/version.js b/js/version.js index 4780f088..fcba6cd9 100644 --- a/js/version.js +++ b/js/version.js @@ -1,7 +1,7 @@ var version = (function() { // version is normally bumped when the state needs changing or any new functionality is added - var current = "3.10.2"; + var current = "3.10.3"; var compare = function(a, b) { var pa = a.split(".");