diff --git a/src/components/sounds/sounds.tsx b/src/components/sounds/sounds.tsx index 2263211..0325e6a 100644 --- a/src/components/sounds/sounds.tsx +++ b/src/components/sounds/sounds.tsx @@ -21,6 +21,9 @@ export function Sounds({ functional, id, sounds }: SoundsProps) { const firstNewSound = useRef(null); + const showMoreButton = useRef(null); + const [exitComplete, setExitComplete] = useState(false); + useEffect(() => { if (showAll) { firstNewSound.current?.focus(); @@ -75,12 +78,17 @@ export function Sounds({ functional, id, sounds }: SoundsProps) { {sounds.length > 6 && ( - + setExitComplete(true)} + > setShowAll(prev => !prev)} + onAnimationComplete={() => { + if (!showAll && exitComplete) { + setExitComplete(false); + showMoreButton.current?.focus(); + } + }} > {showAll ? 'Show Less' : 'Show More'}