feat: card composer now auto scrolls into view on being opened
This commit is contained in:
parent
4b83ff594f
commit
edc7b649ec
@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useRef } from 'react';
|
import React, { useState, useRef, useEffect } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import useOnEscapeKeyDown from 'shared/hooks/onEscapeKeyDown';
|
import useOnEscapeKeyDown from 'shared/hooks/onEscapeKeyDown';
|
||||||
import useOnOutsideClick from 'shared/hooks/onOutsideClick';
|
import useOnOutsideClick from 'shared/hooks/onOutsideClick';
|
||||||
@ -25,6 +25,11 @@ const CardComposer = ({ isOpen, onCreateCard, onClose }: Props) => {
|
|||||||
const $cardRef = useRef<HTMLDivElement>(null);
|
const $cardRef = useRef<HTMLDivElement>(null);
|
||||||
useOnOutsideClick($cardRef, true, onClose, null);
|
useOnOutsideClick($cardRef, true, onClose, null);
|
||||||
useOnEscapeKeyDown(isOpen, onClose);
|
useOnEscapeKeyDown(isOpen, onClose);
|
||||||
|
useEffect(() => {
|
||||||
|
if ($cardRef.current) {
|
||||||
|
$cardRef.current.scrollIntoView();
|
||||||
|
}
|
||||||
|
});
|
||||||
return (
|
return (
|
||||||
<CardComposerWrapper isOpen={isOpen} ref={$cardRef}>
|
<CardComposerWrapper isOpen={isOpen} ref={$cardRef}>
|
||||||
<Card
|
<Card
|
||||||
|
Loading…
Reference in New Issue
Block a user