mirror of
https://github.com/arc53/DocsGPT.git
synced 2025-11-29 16:43:16 +00:00
Added Scrollbar visible when popup is opened
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
import { SyntheticEvent, useEffect, useRef, useState } from 'react';
|
||||
import {
|
||||
SyntheticEvent,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
useCallback,
|
||||
} from 'react';
|
||||
import { useSelector } from 'react-redux';
|
||||
import Edit from '../assets/edit.svg';
|
||||
import Exit from '../assets/exit.svg';
|
||||
@@ -76,12 +82,33 @@ export default function ConversationTile({
|
||||
};
|
||||
}, []);
|
||||
|
||||
const preventScroll = useCallback((event: WheelEvent | TouchEvent) => {
|
||||
event.preventDefault();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const conversationsMainDiv = document.getElementById(
|
||||
'conversationsMainDiv',
|
||||
);
|
||||
conversationsMainDiv &&
|
||||
(conversationsMainDiv.style.overflowY = isOpen ? 'hidden' : 'auto');
|
||||
|
||||
if (conversationsMainDiv) {
|
||||
if (isOpen) {
|
||||
conversationsMainDiv.addEventListener('wheel', preventScroll, {
|
||||
passive: false,
|
||||
});
|
||||
conversationsMainDiv.addEventListener('touchmove', preventScroll, {
|
||||
passive: false,
|
||||
});
|
||||
} else {
|
||||
conversationsMainDiv.removeEventListener('wheel', preventScroll);
|
||||
conversationsMainDiv.removeEventListener('touchmove', preventScroll);
|
||||
}
|
||||
|
||||
return () => {
|
||||
conversationsMainDiv.removeEventListener('wheel', preventScroll);
|
||||
conversationsMainDiv.removeEventListener('touchmove', preventScroll);
|
||||
};
|
||||
}
|
||||
}, [isOpen]);
|
||||
|
||||
function onClear() {
|
||||
|
||||
Reference in New Issue
Block a user