fix: leave editor after deleting the open stack (#1665)

* fix: leave editor after deleting the open stack

Clear selection on delete-key identity match, navigate to dashboard only when the editor is visible, and clear mobile detail so the URL writer leaves the deleted stack route instead of a permanent skeleton.

* fix: remove duplicate setIsFileLoading in stack actions test fixture
This commit is contained in:
Anso
2026-07-21 13:16:00 -04:00
committed by GitHub
parent 3f1f15a6f4
commit 55fa29f565
4 changed files with 258 additions and 4 deletions
+9
View File
@@ -208,6 +208,10 @@ export default function EditorLayout() {
// useViewNavigationState needs onNavigateToDashboard -> resetEditorState
// but stackActions isn't created until after navState
const resetEditorStateRef = useRef<() => void>(() => {});
// Mobile state is declared after useStackActions; this ref is assigned once
// pendingDetailStack / mobileView exist so delete-of-open-stack can flip to
// the list surface without reordering the hook graph.
const onDeletedOpenStackRef = useRef<() => void>(() => {});
const navState = useViewNavigationState({
onNavigateToDashboard: () => resetEditorStateRef.current(),
@@ -282,6 +286,7 @@ export default function EditorLayout() {
return can('stack:edit', 'stack', stackName);
},
canOfferVolumeRemoval,
onDeletedOpenStack: () => onDeletedOpenStackRef.current(),
});
// Wire the ref now that stackActions is available
@@ -375,6 +380,10 @@ export default function EditorLayout() {
const [pendingDetailStack, setPendingDetailStack] = useState<string | null>(null);
const [pendingAnatomyTab, setPendingAnatomyTab] = useState<'networking' | 'doctor' | 'dossier' | 'drift' | undefined>();
const [fleetUpdatesIntent, setFleetUpdatesIntent] = useState<{ tab: 'nodes' | 'changelog' } | null>(null);
onDeletedOpenStackRef.current = () => {
setPendingDetailStack(null);
setMobileView('list');
};
const handleFleetUpdatesIntentConsumed = useCallback(() => setFleetUpdatesIntent(null), []);