Skip to content

Commit 2462201

Browse files
committed
bugfix: overlay now redirs nicely
1 parent 6b020f1 commit 2462201

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import js from "@eslint/js";
22
import { defineConfig, globalIgnores } from "eslint/config";
3-
import importPlugin from "eslint-plugin-import"; // ← add this
3+
import importPlugin from "eslint-plugin-import";
44
import reactHooks from "eslint-plugin-react-hooks";
55
import reactRefresh from "eslint-plugin-react-refresh";
66
import globals from "globals";

src/AiidaExplorer/index.jsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect, useRef } from "react";
1+
import React, { useState, useEffect, useRef, useCallback } from "react";
22
import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
33

44
import {
@@ -59,7 +59,7 @@ function AiidaExplorerInner({
5959
const [rootNodeId, setRootNodeId] = useRootNode(
6060
rootNode,
6161
defaultRootNode,
62-
onRootNodeChange
62+
onRootNodeChange,
6363
);
6464

6565
const appRef = useRef(null);
@@ -164,7 +164,7 @@ function AiidaExplorerInner({
164164
instance.fitView({ padding: 2.0 });
165165

166166
const centralNode = nodesWithExtras.find(
167-
(n) => stripSyntheticId(n.id) === stripSyntheticId(rootNodeId)
167+
(n) => stripSyntheticId(n.id) === stripSyntheticId(rootNodeId),
168168
);
169169
if (centralNode?.position) {
170170
let zoom = 1.22;
@@ -175,21 +175,21 @@ function AiidaExplorerInner({
175175
instance.setCenter(
176176
centralNode.position.x + 70,
177177
centralNode.position.y,
178-
{ zoom, duration: 500 }
178+
{ zoom, duration: 500 },
179179
);
180180
// zoom back in
181181
setTimeout(() => {
182182
instance.setCenter(
183183
centralNode.position.x + 70,
184184
centralNode.position.y + 0,
185-
{ zoom: zoom, duration: 500 }
185+
{ zoom: zoom, duration: 500 },
186186
);
187187
}, 400);
188188
}
189189
});
190190

191191
const rootNode = nodesWithExtras.find(
192-
(n) => stripSyntheticId(n.id) === stripSyntheticId(rootNodeId)
192+
(n) => stripSyntheticId(n.id) === stripSyntheticId(rootNodeId),
193193
);
194194
if (rootNode) {
195195
const enrichedNode = await ensureNodeData(rootNode);
@@ -231,7 +231,7 @@ function AiidaExplorerInner({
231231
restApiUrl,
232232
node,
233233
extraNodeData,
234-
downloadFormats
234+
downloadFormats,
235235
);
236236
setExtraNodeData((prev) => ({
237237
...prev,
@@ -259,8 +259,8 @@ function AiidaExplorerInner({
259259
prev.map((n) =>
260260
stripSyntheticId(n.id) === stripSyntheticId(node.id)
261261
? { ...n, data: { ...n.data, ...enrichedNode.data } }
262-
: n
263-
)
262+
: n,
263+
),
264264
);
265265
};
266266

@@ -281,6 +281,15 @@ function AiidaExplorerInner({
281281
setRootNodeId(stripSyntheticId(node.id));
282282
};
283283

284+
// --- Navigation from modals --- //
285+
const navigateFromOverlay = useCallback(
286+
(nodeId) => {
287+
setActiveOverlay(null);
288+
setRootNodeId(nodeId);
289+
},
290+
[setRootNodeId],
291+
);
292+
284293
return (
285294
<div ref={appRef} className="ae:flex ae:flex-col ae:h-full">
286295
<OverlayProvider
@@ -306,7 +315,7 @@ function AiidaExplorerInner({
306315
{activeOverlay === "groupsview" && (
307316
<GroupsViewer
308317
restApiUrl={restApiUrl}
309-
setRootNodeId={setRootNodeId}
318+
setRootNodeId={navigateFromOverlay}
310319
/>
311320
)}
312321
{activeOverlay === "helpview" && <HelpViewer />}

0 commit comments

Comments
 (0)