Don't scroll to the bottom of story replies
This commit is contained in:
parent
004abd44b5
commit
77bf3a8669
2 changed files with 13 additions and 3 deletions
|
@ -136,6 +136,7 @@ export const StoryViewsNRepliesModal = ({
|
|||
}: PropsType): JSX.Element | null => {
|
||||
const containerElementRef = useRef<HTMLDivElement | null>(null);
|
||||
const inputApiRef = useRef<InputApi | undefined>();
|
||||
const shouldScrollToBottomRef = useRef(false);
|
||||
const [bottom, setBottom] = useState<HTMLDivElement | null>(null);
|
||||
const [messageBodyText, setMessageBodyText] = useState('');
|
||||
const [showReactionPicker, setShowReactionPicker] = useState(false);
|
||||
|
@ -164,14 +165,15 @@ export const StoryViewsNRepliesModal = ({
|
|||
strategy: 'fixed',
|
||||
});
|
||||
|
||||
let composerElement: JSX.Element | undefined;
|
||||
|
||||
useEffect(() => {
|
||||
if (replies.length) {
|
||||
if (replies.length && shouldScrollToBottomRef.current) {
|
||||
bottom?.scrollIntoView({ behavior: 'smooth' });
|
||||
shouldScrollToBottomRef.current = false;
|
||||
}
|
||||
}, [bottom, replies.length]);
|
||||
|
||||
let composerElement: JSX.Element | undefined;
|
||||
|
||||
if (canReply) {
|
||||
composerElement = (
|
||||
<>
|
||||
|
@ -204,6 +206,7 @@ export const StoryViewsNRepliesModal = ({
|
|||
onPickEmoji={insertEmoji}
|
||||
onSubmit={(...args) => {
|
||||
inputApiRef.current?.reset();
|
||||
shouldScrollToBottomRef.current = true;
|
||||
onReply(...args);
|
||||
}}
|
||||
onTextTooLong={onTextTooLong}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue