fix: restore Escape key support in LayoutShell (was overwritten by other task)

This commit is contained in:
Investor Flow Build
2026-07-03 22:57:49 -04:00
parent 3b04edefba
commit 1e818c0881
2 changed files with 67 additions and 83 deletions
+32
View File
@@ -0,0 +1,32 @@
"use client";
import { createContext, useContext, useState, type ReactNode } from "react";
/**
* Shared context for tracking which CollapsibleSection is currently open.
* Used by LayoutShell to implement Escape-to-close across all panels.
*/
interface CollapsibleContextValue {
/** The id of the currently open section, or null if all are collapsed */
openSectionId: string | null;
/** Set the open section. Pass null to close all. */
setOpenSectionId: (id: string | null) => void;
}
const CollapsibleContext = createContext<CollapsibleContextValue>({
openSectionId: null,
setOpenSectionId: () => {},
});
export function CollapsibleProvider({ children }: { children: ReactNode }) {
const [openSectionId, setOpenSectionId] = useState<string | null>(null);
return (
<CollapsibleContext.Provider value={{ openSectionId, setOpenSectionId }}>
{children}
</CollapsibleContext.Provider>
);
}
export function useCollapsibleContext() {
return useContext(CollapsibleContext);
}