fix: restore Escape key support in LayoutShell (was overwritten by other task)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user