mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix popover scroll button WhatsNewPopup hiding (#19017)
Co-authored-by: David Walsh <davidwalsh83@gmail.com>
This commit is contained in:
parent
09b113e0df
commit
4cb3284136
@ -3,6 +3,7 @@ import { useHistory } from 'react-router-dom';
|
|||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
import { debounce } from 'lodash';
|
||||||
import { getCurrentLocale } from '../../../ducks/locale/locale';
|
import { getCurrentLocale } from '../../../ducks/locale/locale';
|
||||||
import { I18nContext } from '../../../contexts/i18n';
|
import { I18nContext } from '../../../contexts/i18n';
|
||||||
import { useEqualityCheck } from '../../../hooks/useEqualityCheck';
|
import { useEqualityCheck } from '../../../hooks/useEqualityCheck';
|
||||||
@ -238,6 +239,16 @@ export default function WhatsNewPopup({ onClose }) {
|
|||||||
|
|
||||||
const trackEvent = useContext(MetaMetricsContext);
|
const trackEvent = useContext(MetaMetricsContext);
|
||||||
|
|
||||||
|
const handleDebouncedScroll = debounce((target) => {
|
||||||
|
setShouldShowScrollButton(
|
||||||
|
target.scrollHeight - target.scrollTop !== target.clientHeight,
|
||||||
|
);
|
||||||
|
}, 100);
|
||||||
|
|
||||||
|
const handleScroll = (e) => {
|
||||||
|
handleDebouncedScroll(e.target);
|
||||||
|
};
|
||||||
|
|
||||||
const handleScrollDownClick = (e) => {
|
const handleScrollDownClick = (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
idRefMap[notifications[notifications.length - 1].id].current.scrollIntoView(
|
idRefMap[notifications[notifications.length - 1].id].current.scrollIntoView(
|
||||||
@ -245,7 +256,6 @@ export default function WhatsNewPopup({ onClose }) {
|
|||||||
behavior: 'smooth',
|
behavior: 'smooth',
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
setShouldShowScrollButton(false);
|
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const observer = new window.IntersectionObserver(
|
const observer = new window.IntersectionObserver(
|
||||||
@ -300,6 +310,7 @@ export default function WhatsNewPopup({ onClose }) {
|
|||||||
popoverRef={popoverRef}
|
popoverRef={popoverRef}
|
||||||
showScrollDown={shouldShowScrollButton && notifications.length > 1}
|
showScrollDown={shouldShowScrollButton && notifications.length > 1}
|
||||||
onScrollDownButtonClick={handleScrollDownClick}
|
onScrollDownButtonClick={handleScrollDownClick}
|
||||||
|
onScroll={handleScroll}
|
||||||
>
|
>
|
||||||
<div className="whats-new-popup__notifications">
|
<div className="whats-new-popup__notifications">
|
||||||
{notifications.map(({ id }, index) => {
|
{notifications.map(({ id }, index) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user