Skip to content

Commit

Permalink
🚧 work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
scar055 committed Jan 31, 2024
1 parent 994352a commit ec9e665
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions packages/next-templates/src/app/FigureDetails/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
Button,
Drawer,
Figure,
Paragraph,
Table,
TableBody,
TableCell,
Expand All @@ -14,7 +13,7 @@ import {
TableRow,
} from '@utrecht/component-library-react';
import { VegaVisualization } from '@utrecht/component-library-react/dist/VegaVisualization';
import React, { HTMLAttributes, PropsWithChildren, createRef, useState } from 'react';
import React, { HTMLAttributes, PropsWithChildren, createRef, useCallback, useEffect, useState } from 'react';
import './styles/FigureDetails.css';

interface FigureDetailsProps extends Omit<HTMLAttributes<HTMLLIElement>, 'children'> {
Expand Down Expand Up @@ -43,6 +42,27 @@ export const FigureDetails = ({
drawer.current?.close();
};

const handleFocus = useCallback<EventListener>(
(event) => {
const isInsideNav = drawer.current?.contains(event.target as Node);
if (!isInsideNav) {
closeModal;
}
},
[drawer],
);

useEffect(() => {
//TODO: Remove eventlistener if element is not rendered anymore
drawer.current?.ownerDocument.addEventListener('focus', handleFocus, true);
}, []);

const handleKeyDown = (evt: KeyboardEvent) => {
if (evt.key === 'Escape') {
closeModal;
}
};

let FigureDetails = (
<div>
<Button onClick={showModal}>{openButtonText}</Button>
Expand Down

0 comments on commit ec9e665

Please sign in to comment.