Fix clicking accessibility
This commit is contained in:
parent
51c8d06569
commit
cf07001036
4 changed files with 22 additions and 13 deletions
18
src/helper/accessibility.ts
Normal file
18
src/helper/accessibility.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
let isSpaceClickActive = false;
|
||||||
|
|
||||||
|
export const addSupportForTabNavigation = () =>
|
||||||
|
document.addEventListener('keydown', (e) => {
|
||||||
|
if (e.key === ' ') {
|
||||||
|
isSpaceClickActive = true;
|
||||||
|
(document.activeElement as HTMLElement)?.click();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const removeUnnecessaryOutlines = () =>
|
||||||
|
document.addEventListener('click', () => {
|
||||||
|
if (!isSpaceClickActive) {
|
||||||
|
(document.activeElement as HTMLElement).blur?.();
|
||||||
|
}
|
||||||
|
isSpaceClickActive = false;
|
||||||
|
});
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
export const addSupportForTabNavigation = () =>
|
|
||||||
document.addEventListener('keydown', (e) => {
|
|
||||||
if (e.key === ' ') {
|
|
||||||
(document.activeElement as HTMLElement)?.click();
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
export const removeUnnecessaryOutlines = () =>
|
|
||||||
document.addEventListener('click', () =>
|
|
||||||
(document.activeElement as HTMLElement).blur?.()
|
|
||||||
);
|
|
||||||
|
|
@ -9,8 +9,10 @@ import '../static/no-change/favicons/site.webmanifest';
|
||||||
import '../static/no-change/og-image.jpg';
|
import '../static/no-change/og-image.jpg';
|
||||||
import '../static/no-change/robots.txt';
|
import '../static/no-change/robots.txt';
|
||||||
import { createPortfolio } from './data/create-portfolio';
|
import { createPortfolio } from './data/create-portfolio';
|
||||||
import { addSupportForTabNavigation } from './helper/add-support-for-tab-navigation';
|
import {
|
||||||
import { removeUnnecessaryOutlines } from './helper/remove-unnecessary-outlines';
|
addSupportForTabNavigation,
|
||||||
|
removeUnnecessaryOutlines,
|
||||||
|
} from './helper/accessibility';
|
||||||
import { scrollToFragment } from './helper/scroll-to-fragment';
|
import { scrollToFragment } from './helper/scroll-to-fragment';
|
||||||
import './styles.scss';
|
import './styles.scss';
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue