fix: Gantt chart bugs (#2024)

* fix: only left mouse button should trigger all the events

* fix: extra block shadow
This commit is contained in:
Aaryan Khandelwal 2023-09-01 11:23:43 +05:30 committed by GitHub
parent 3a0d96a48d
commit 0d4bcd2758
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,9 +73,11 @@ export const ChartDraggable: React.FC<Props> = ({
}; };
// handle block resize from the left end // handle block resize from the left end
const handleBlockLeftResize = () => { const handleBlockLeftResize = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
if (!currentViewData || !resizableRef.current || !block.position) return; if (!currentViewData || !resizableRef.current || !block.position) return;
if (e.button !== 0) return;
const resizableDiv = resizableRef.current; const resizableDiv = resizableRef.current;
const columnWidth = currentViewData.data.width; const columnWidth = currentViewData.data.width;
@ -126,9 +128,11 @@ export const ChartDraggable: React.FC<Props> = ({
}; };
// handle block resize from the right end // handle block resize from the right end
const handleBlockRightResize = () => { const handleBlockRightResize = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
if (!currentViewData || !resizableRef.current || !block.position) return; if (!currentViewData || !resizableRef.current || !block.position) return;
if (e.button !== 0) return;
const resizableDiv = resizableRef.current; const resizableDiv = resizableRef.current;
const columnWidth = currentViewData.data.width; const columnWidth = currentViewData.data.width;
@ -173,6 +177,8 @@ export const ChartDraggable: React.FC<Props> = ({
const handleBlockMove = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => { const handleBlockMove = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
if (!enableBlockMove || !currentViewData || !resizableRef.current || !block.position) return; if (!enableBlockMove || !currentViewData || !resizableRef.current || !block.position) return;
if (e.button !== 0) return;
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@ -266,7 +272,7 @@ export const ChartDraggable: React.FC<Props> = ({
<div <div
id={`block-${block.id}`} id={`block-${block.id}`}
ref={resizableRef} ref={resizableRef}
className="relative group cursor-pointer font-medium rounded shadow-sm h-full inline-flex items-center transition-all" className="relative group cursor-pointer font-medium h-full inline-flex items-center transition-all"
style={{ style={{
marginLeft: `${block.position?.marginLeft}px`, marginLeft: `${block.position?.marginLeft}px`,
width: `${block.position?.width}px`, width: `${block.position?.width}px`,