Skip to content

Commit

Permalink
fixed accesiblity
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaBonde committed Aug 28, 2024
1 parent 6181b2e commit 81cf3f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/hemsedal24/bilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function Bilder() {
* @see https://docs.uploadthing.com/api-reference/react#uploadbutton
*/
endpoint="videoAndImage"
onClientUploadComplete={(res: any) => {
onClientUploadComplete={(_: any) => {
fetchFiles();
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/hemsedal24/components/Files.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function Files({ data }: any) {
{data.files.length > 0 ?
<div id="pictureContainer" className={styles.container}>
{data.files.map((file:any, index:number) =>
<div key={file.id} className={styles.image} onClick={()=>imageClicked(file.id, index)}>
<div key={file.id} className={styles.image} onClick={()=>imageClicked(file.id, index)} onKeyDown={()=>imageClicked(file.id, index)}>

Check failure on line 29 in src/hemsedal24/components/Files.tsx

View workflow job for this annotation

GitHub Actions / eslint

Avoid non-native interactive elements. If using native HTML is not possible, add an appropriate role and support for tabbing, mouse, keyboard, and touch inputs to an interactive content element
<img src={`https://utfs.io/f/${file.key}`} alt={` ${file.name}`}/></div>)} </div> :<div className={styles.nopictures}><h4>Ingen bilder ennå!</h4></div>}

{isPopoverOpen && (
Expand Down
10 changes: 9 additions & 1 deletion src/hemsedal24/components/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,17 @@ const Popover: React.FC<PopoverProps> = ({ onClose, children }) => {
};
}, [onClose]);

const handleKeyDown = (event: KeyboardEvent) => {
if (event.key === 'Escape' || event.key === 'Enter') {
if (popoverRef.current && !popoverRef.current.contains(event.target as Node)) {
onClose();
}}
};
document.addEventListener('keydown', handleKeyDown);

return (
<>
<div className={styles.backdrop} onClick={onClose}> </div>
<div className={styles.backdrop} onClick={onClose} tabIndex={0} role='button' aria-label="Close popover"> </div>

Check failure on line 36 in src/hemsedal24/components/Popover.tsx

View workflow job for this annotation

GitHub Actions / eslint

Visible, non-interactive elements with click handlers must have at least one keyboard listener
<div ref={popoverRef} className={styles.popover_content}>
{children}
</div>
Expand Down

0 comments on commit 81cf3f0

Please sign in to comment.