From c56c5bd1451cf12afe2647a09245be1ac38d2e62 Mon Sep 17 00:00:00 2001 From: Horatiu Muresan Date: Tue, 27 Sep 2022 16:00:44 +0300 Subject: [PATCH] fix(polls) Fix autoscroll for polls causing layout issues --- .../features/polls/components/web/PollsList.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/react/features/polls/components/web/PollsList.js b/react/features/polls/components/web/PollsList.js index d22bf3a28..9dbce9d26 100644 --- a/react/features/polls/components/web/PollsList.js +++ b/react/features/polls/components/web/PollsList.js @@ -1,10 +1,12 @@ // @flow -import React, { useEffect, useRef } from 'react'; +import React, { useCallback, useEffect, useRef } from 'react'; import { useTranslation } from 'react-i18next'; import { useSelector } from 'react-redux'; + import { Icon, IconChatUnread } from '../../../base/icons'; +import { browser } from '../../../base/lib-jitsi-meet'; import PollItem from './PollItem'; @@ -14,11 +16,19 @@ const PollsList = () => { const polls = useSelector(state => state['features/polls'].polls); const pollListEndRef = useRef(null); - const scrollToBottom = () => { + const scrollToBottom = useCallback(() => { if (pollListEndRef.current) { - pollListEndRef.current.scrollIntoView({ behavior: 'smooth' }); + // Safari does not support options + const param = browser.isSafari() + ? false : { + behavior: 'smooth', + block: 'end', + inline: 'nearest' + }; + + pollListEndRef.current.scrollIntoView(param); } - }; + }, [ pollListEndRef.current ]); useEffect(() => { scrollToBottom();