[Refactoring] Simplify disableScrolling/enableScrolling
This commit is contained in:
parent
03de021b82
commit
a59a3a4217
@ -24,19 +24,21 @@ import {
|
||||
} from '../../global/helpers';
|
||||
import {
|
||||
selectBot,
|
||||
selectCanManage, selectCanTranslateChat,
|
||||
selectCanManage,
|
||||
selectCanTranslateChat,
|
||||
selectChat,
|
||||
selectChatFullInfo,
|
||||
selectCurrentMessageList,
|
||||
selectIsChatWithSelf,
|
||||
selectIsPremiumPurchaseBlocked,
|
||||
selectIsRightColumnShown, selectNotifyExceptions,
|
||||
selectIsRightColumnShown,
|
||||
selectNotifyExceptions,
|
||||
selectNotifySettings,
|
||||
selectTabState,
|
||||
selectUser,
|
||||
selectUserFullInfo,
|
||||
} from '../../global/selectors';
|
||||
import { disableScrolling, enableScrolling } from '../../util/scrollLock';
|
||||
import { disableScrolling } from '../../util/scrollLock';
|
||||
|
||||
import useAppLayout from '../../hooks/useAppLayout';
|
||||
import useFlag from '../../hooks/useFlag';
|
||||
@ -391,11 +393,7 @@ const HeaderMenuContainer: FC<OwnProps & StateProps> = ({
|
||||
closeMenu();
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
disableScrolling();
|
||||
|
||||
return enableScrolling;
|
||||
}, []);
|
||||
useEffect(disableScrolling, []);
|
||||
|
||||
const lang = useOldLang();
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ import type { IAnchorPosition } from '../../../types';
|
||||
|
||||
import { getUserFullName, isUserId } from '../../../global/helpers';
|
||||
import buildClassName from '../../../util/buildClassName';
|
||||
import { disableScrolling, enableScrolling } from '../../../util/scrollLock';
|
||||
import { disableScrolling } from '../../../util/scrollLock';
|
||||
import { REM } from '../../common/helpers/mediaDimensions';
|
||||
import renderText from '../../common/helpers/renderText';
|
||||
import { getMessageCopyOptions } from './helpers/copyOptions';
|
||||
@ -323,9 +323,7 @@ const MessageContextMenu: FC<OwnProps> = ({
|
||||
}, [isOpen, markIsReady, unmarkIsReady]);
|
||||
|
||||
useEffect(() => {
|
||||
disableScrolling(scrollableRef.current, '.ReactionPicker');
|
||||
|
||||
return enableScrolling;
|
||||
return disableScrolling(scrollableRef.current, '.ReactionPicker');
|
||||
}, [isOpen]);
|
||||
|
||||
const handleOpenMessageReactionPicker = useLastCallback((position: IAnchorPosition) => {
|
||||
|
||||
@ -67,6 +67,8 @@ export function disableScrolling(el?: HTMLElement | null, _excludedClosestSelect
|
||||
document.addEventListener('wheel', preventDefault, { passive: false });
|
||||
document.addEventListener('touchmove', preventDefault, { passive: false });
|
||||
document.onkeydown = preventDefaultForScrollKeys;
|
||||
|
||||
return enableScrolling;
|
||||
}
|
||||
|
||||
export function enableScrolling() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user