diff --git a/packages/geoview-core/src/core/components/common/use-lightbox.tsx b/packages/geoview-core/src/core/components/common/use-lightbox.tsx index 0568ed5b95f..41947cc1d6b 100644 --- a/packages/geoview-core/src/core/components/common/use-lightbox.tsx +++ b/packages/geoview-core/src/core/components/common/use-lightbox.tsx @@ -1,6 +1,7 @@ import { useState } from 'react'; import { Box } from '@/ui'; import { LightBoxSlides, LightboxImg } from '@/core/components/lightbox/lightbox'; +import { useUIActiveTrapGeoView } from '@/core/stores/store-interface-and-intial-values/ui-state'; interface UseLightBoxReturnType { initLightBox: (images: string, alias: string, index: number | undefined, scale?: number) => void; @@ -12,10 +13,15 @@ interface UseLightBoxReturnType { * @returns {UseLightBoxReturnType} */ export function useLightBox(): UseLightBoxReturnType { + // Internal state const [isLightBoxOpen, setIsLightBoxOpen] = useState(false); const [slides, setSlides] = useState([]); const [slidesIndex, setSlidesIndex] = useState(0); const [imgScale, setImgScale] = useState(); + const [aliasIndex, setAliasIndex] = useState('0'); + + // Store state + const activeTrapGeoView = useUIActiveTrapGeoView(); /** * Initialize lightbox with state. @@ -35,6 +41,7 @@ export function useLightBox(): UseLightBoxReturnType { setSlides(slidesList); setSlidesIndex(index ?? 0); setImgScale(scale); + setAliasIndex(alias.split('_')[0]); }; /** @@ -42,6 +49,7 @@ export function useLightBox(): UseLightBoxReturnType { * @returns {JSX.Element} */ function LightBoxComponent(): JSX.Element { + // TODO: fix bug https://github.com/Canadian-Geospatial-Platform/geoview/issues/2553 return isLightBoxOpen ? ( { + const element = document.querySelector(`.returnLightboxFocusItem-${aliasIndex}`) as HTMLElement; + element?.focus(); + element?.classList.add('keyboard-focused'); + }, 250); + } }} /> ) : ( diff --git a/packages/geoview-core/src/core/components/data-table/data-table.tsx b/packages/geoview-core/src/core/components/data-table/data-table.tsx index e26d8e83e6c..cbce98f6667 100644 --- a/packages/geoview-core/src/core/components/data-table/data-table.tsx +++ b/packages/geoview-core/src/core/components/data-table/data-table.tsx @@ -136,6 +136,7 @@ function DataTable({ data, layerPath, tableHeight = '500px' }: DataTableProps):