fix: clear models expand keys
This commit is contained in:
@@ -104,6 +104,10 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = ({
|
||||
};
|
||||
|
||||
const handleMouseEnter = (e: React.MouseEvent<HTMLCanvasElement>) => {
|
||||
if (disabled) {
|
||||
overlayCanvasRef.current!.style.cursor = 'default';
|
||||
return;
|
||||
}
|
||||
overlayCanvasRef.current!.style.cursor = 'none';
|
||||
cursorRef.current!.style.display = 'block';
|
||||
cursorRef.current!.style.top = `${e.clientY}px`;
|
||||
@@ -111,6 +115,9 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = ({
|
||||
};
|
||||
|
||||
const handleMouseMove = (e: React.MouseEvent<HTMLCanvasElement>) => {
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
overlayCanvasRef.current!.style.cursor = 'none';
|
||||
cursorRef.current!.style.display = 'block';
|
||||
cursorRef.current!.style.top = `${e.clientY}px`;
|
||||
@@ -118,6 +125,9 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = ({
|
||||
};
|
||||
|
||||
const handleMouseLeave = () => {
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
overlayCanvasRef.current!.style.cursor = 'default';
|
||||
cursorRef.current!.style.display = 'none';
|
||||
};
|
||||
@@ -284,6 +294,9 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = ({
|
||||
}, []);
|
||||
|
||||
const draw = (e: React.MouseEvent<HTMLCanvasElement>) => {
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
if (!isDrawing.current) return;
|
||||
|
||||
const { offsetX, offsetY } = e.nativeEvent;
|
||||
@@ -315,6 +328,9 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = ({
|
||||
};
|
||||
|
||||
const startDrawing = (e: React.MouseEvent<HTMLCanvasElement>) => {
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
isDrawing.current = true;
|
||||
|
||||
currentStroke.current = [];
|
||||
@@ -340,6 +356,9 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = ({
|
||||
|
||||
const endDrawing = (e: React.MouseEvent<HTMLCanvasElement>) => {
|
||||
console.log('End Drawing:', e);
|
||||
if (disabled) {
|
||||
return;
|
||||
}
|
||||
if (!isDrawing.current) {
|
||||
return;
|
||||
}
|
||||
@@ -610,13 +629,13 @@ const CanvasImageEditor: React.FC<CanvasImageEditorProps> = ({
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (disabled) {
|
||||
overlayCanvasRef.current!.style.pointerEvents = 'none';
|
||||
} else {
|
||||
overlayCanvasRef.current!.style.pointerEvents = 'auto';
|
||||
}
|
||||
}, [disabled]);
|
||||
// useEffect(() => {
|
||||
// if (disabled) {
|
||||
// overlayCanvasRef.current!.style.pointerEvents = 'none';
|
||||
// } else {
|
||||
// overlayCanvasRef.current!.style.pointerEvents = 'auto';
|
||||
// }
|
||||
// }, [disabled]);
|
||||
|
||||
return (
|
||||
<div className="editor-wrapper">
|
||||
|
||||
@@ -183,6 +183,20 @@ const TableRow: React.FC<
|
||||
}
|
||||
}, [expanded]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleVisibilityChange = async () => {
|
||||
if (document.visibilityState === 'hidden') {
|
||||
cacheDataListRef.current = [];
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener('visibilitychange', handleVisibilityChange);
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!firstLoad && expanded) {
|
||||
cacheDataListRef.current = childrenData;
|
||||
|
||||
@@ -18,3 +18,16 @@
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
|
||||
.tags-wrapper-dropdown {
|
||||
.ant-dropdown-menu {
|
||||
.ant-dropdown-menu-item {
|
||||
background-color: transparent;
|
||||
cursor: default;
|
||||
|
||||
&:hover {
|
||||
background-color: transparent;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,10 @@ const TagsWrapper: React.FC<TagsWrapperProps> = (props) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleClick = (data: any) => {
|
||||
data.domEvent?.stopPropagation();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (tagsContentRef.current) {
|
||||
calculateHiddenIndices();
|
||||
@@ -98,13 +102,15 @@ const TagsWrapper: React.FC<TagsWrapperProps> = (props) => {
|
||||
{hiddenIndices.end < dataList.length && (
|
||||
<Dropdown
|
||||
trigger={['hover']}
|
||||
overlayClassName="tags-wrapper-dropdown"
|
||||
menu={{
|
||||
items: _.map(
|
||||
_.slice(dataList, hiddenIndices.end),
|
||||
(item: any, index: number) => {
|
||||
return {
|
||||
label: renderTag?.(item),
|
||||
key: index
|
||||
key: index,
|
||||
onClick: handleClick
|
||||
};
|
||||
}
|
||||
)
|
||||
|
||||
@@ -127,7 +127,7 @@ const Models: React.FC<ModelsProps> = ({
|
||||
loading,
|
||||
total
|
||||
}) => {
|
||||
const [expandAtom] = useAtom(modelsExpandKeysAtom);
|
||||
const [expandAtom, setExpandAtom] = useAtom(modelsExpandKeysAtom);
|
||||
const access = useAccess();
|
||||
const intl = useIntl();
|
||||
const navigate = useNavigate();
|
||||
@@ -227,6 +227,12 @@ const Models: React.FC<ModelsProps> = ({
|
||||
}
|
||||
}, [deleteIds]);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
setExpandAtom([]);
|
||||
};
|
||||
}, []);
|
||||
|
||||
const sourceOptions = [
|
||||
{
|
||||
label: intl.formatMessage({ id: 'menu.models.modelCatalog' }),
|
||||
|
||||
@@ -43,21 +43,20 @@ const Models: React.FC = () => {
|
||||
categories: []
|
||||
});
|
||||
|
||||
const { updateChunkedList, cacheDataListRef, deletedIdsRef } =
|
||||
useUpdateChunkedList({
|
||||
events: ['UPDATE'],
|
||||
dataList: dataSource.dataList,
|
||||
setDataList(list, opts?: any) {
|
||||
setDataSource((pre) => {
|
||||
return {
|
||||
total: pre.total,
|
||||
loading: false,
|
||||
dataList: list,
|
||||
deletedIds: opts?.deletedIds || []
|
||||
};
|
||||
});
|
||||
}
|
||||
});
|
||||
const { updateChunkedList, cacheDataListRef } = useUpdateChunkedList({
|
||||
events: ['UPDATE'],
|
||||
dataList: dataSource.dataList,
|
||||
setDataList(list, opts?: any) {
|
||||
setDataSource((pre) => {
|
||||
return {
|
||||
total: pre.total,
|
||||
loading: false,
|
||||
dataList: list,
|
||||
deletedIds: opts?.deletedIds || []
|
||||
};
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const getWorkerList = async () => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user