Skip to content

Commit d556a76

Browse files
authored
fix: selected model missing when switch between pages (#922)
1 parent 23d6393 commit d556a76

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

frontend/packages/core/src/components/Loader/RunList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ const RunList: FunctionComponent<{count?: number}> = ({count}) => {
2222
return (
2323
<ContentLoader viewBox={`0 0 220 ${(count ?? 2) * 36}`}>
2424
{Array.from({length: count ?? 2}).map((_, i) => (
25-
<>
25+
<React.Fragment key={i}>
2626
<rect x="0" y={`${11 * (i + 1) + 25 * i + 4.5}`} width="16" height="16" />
2727
<circle cx="32" cy={`${11 * (i + 1) + 25 * i + 12.5}`} r="6" />
2828
<rect x="46" y={`${11 * (i + 1) + 25 * i + 5.5}`} rx="3" ry="3" width="100" height="14" />
29-
</>
29+
</React.Fragment>
3030
))}
3131
</ContentLoader>
3232
);

frontend/packages/core/src/pages/graph.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ const Graph: FunctionComponent = () => {
9494
const graph = useRef<GraphRef>(null);
9595
const file = useRef<HTMLInputElement>(null);
9696
const [files, setFiles] = useState<FileList | File[] | null>(storeModel);
97+
const setModelFile = useCallback(
98+
(f: FileList | File[]) => {
99+
storeDispatch(actions.graph.setModel(f));
100+
setFiles(f);
101+
},
102+
[storeDispatch]
103+
);
97104
const onClickFile = useCallback(() => {
98105
if (file.current) {
99106
file.current.value = '';
@@ -104,11 +111,10 @@ const Graph: FunctionComponent = () => {
104111
(e: React.ChangeEvent<HTMLInputElement>) => {
105112
const target = e.target;
106113
if (target && target.files && target.files.length) {
107-
storeDispatch(actions.graph.setModel(target.files));
108-
setFiles(target.files);
114+
setModelFile(target.files);
109115
}
110116
},
111-
[storeDispatch]
117+
[setModelFile]
112118
);
113119

114120
const {data, loading} = useRequest<BlobResponse>(files ? null : '/graph/graph');
@@ -280,7 +286,10 @@ const Graph: FunctionComponent = () => {
280286
nodeDocumentation
281287
]);
282288

283-
const uploader = useMemo(() => <Uploader onClickUpload={onClickFile} onDropFiles={setFiles} />, [onClickFile]);
289+
const uploader = useMemo(() => <Uploader onClickUpload={onClickFile} onDropFiles={setModelFile} />, [
290+
onClickFile,
291+
setModelFile
292+
]);
284293

285294
return (
286295
<>

0 commit comments

Comments
 (0)