Skip to content

Commit

Permalink
fix(front): fixes focusTrap loop index and removes border on focus-vi…
Browse files Browse the repository at this point in the history
…sible
  • Loading branch information
dgrebb committed Oct 11, 2023
1 parent e9dd6d6 commit c36e94d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
10 changes: 5 additions & 5 deletions front/src/lib/_utils/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
*/
export const focusTrap = (node, enabled) => {
if (!enabled) return false;
var focusableEls = node.querySelectorAll(
'a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])'
);
var firstFocusableEl = focusableEls[0];
var lastFocusableEl = focusableEls[focusableEls.length - 1];

node.addEventListener('keydown', function (e) {
var focusableEls = node.querySelectorAll(
'a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])'
);
var firstFocusableEl = focusableEls[0];
var lastFocusableEl = focusableEls[focusableEls.length - 1];
var isTab = e.key === 'Tab' || e.keyCode === 9;
var isEsc = e.key === 'Escape' || e.keyCode === 27;
if (isTab) {
Expand Down
32 changes: 17 additions & 15 deletions front/src/lib/components/PageNav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,23 @@
{#if categories && categories.length}
<h2>Categories</h2>
<ul class="page-navigation-list">
<li class="page-navigation-category-all">
<a
on:click={(e) => {
categoryClick(pathname, name);
setActiveLink(e);
if (mini) pageFenceClickHandler();
}}
href="/posts/category/all/"
class="transition-link"
class:active={category === 'all'}
use:activeLink
>
All
</a>
</li>
{#if !contents}
<li class="page-navigation-category-all">
<a
on:click={(e) => {
categoryClick(pathname, name);
setActiveLink(e);
if (mini) pageFenceClickHandler();
}}
href="/posts/category/all/"
class="transition-link"
class:active={category === 'all'}
use:activeLink
>
All
</a>
</li>
{/if}
{#each categories as { attributes: { name, slug } }, i}
<li>
<a
Expand Down
1 change: 1 addition & 0 deletions front/src/lib/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
text-rendering: optimizeLegibility !important;
:focus-visible {
outline-offset: 0.25rem;
border-bottom: 0 !important;
}
}

Expand Down

0 comments on commit c36e94d

Please sign in to comment.