From edc7b649ec6460d8e771c5bbc43851501499eca7 Mon Sep 17 00:00:00 2001 From: Jordan Knott Date: Tue, 5 Jan 2021 19:02:19 -0600 Subject: [PATCH] feat: card composer now auto scrolls into view on being opened --- frontend/src/shared/components/CardComposer/index.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/src/shared/components/CardComposer/index.tsx b/frontend/src/shared/components/CardComposer/index.tsx index ace4c25..a350ec5 100644 --- a/frontend/src/shared/components/CardComposer/index.tsx +++ b/frontend/src/shared/components/CardComposer/index.tsx @@ -1,4 +1,4 @@ -import React, { useState, useRef } from 'react'; +import React, { useState, useRef, useEffect } from 'react'; import PropTypes from 'prop-types'; import useOnEscapeKeyDown from 'shared/hooks/onEscapeKeyDown'; import useOnOutsideClick from 'shared/hooks/onOutsideClick'; @@ -25,6 +25,11 @@ const CardComposer = ({ isOpen, onCreateCard, onClose }: Props) => { const $cardRef = useRef(null); useOnOutsideClick($cardRef, true, onClose, null); useOnEscapeKeyDown(isOpen, onClose); + useEffect(() => { + if ($cardRef.current) { + $cardRef.current.scrollIntoView(); + } + }); return (