Closed ghengeveld closed 2 weeks ago
To resolve the api.collapseAll is not a function
error, implement the collapseAll
function in the API and ensure it is correctly referenced in the Menu.tsx
file.
Implement collapseAll
in the API:
toggleNav
, toggleToolbar
, etc., are defined.collapseAll
function.// Example API implementation
export const collapseAll = () => {
// Logic to collapse all items
};
Update Menu.tsx
:
collapseAll
is correctly imported and used in the useMenu
hook.import { collapseAll } from 'path-to-api';
const collapse = useMemo(
() => ({
id: 'collapse',
title: 'Collapse all',
onClick: () => api.collapseAll(),
right: enableShortcuts ? <Shortcut keys={shortcutKeys.collapseAll} /> : null,
}),
[api, enableShortcuts, shortcutKeys]
);
Ensure useExpanded.ts
handles collapse events:
useExpanded
correctly listens for STORIES_COLLAPSE_ALL
events and calls the collapseAll
function.useEffect(() => {
if (!api) return noop;
api.on(STORIES_COLLAPSE_ALL, collapseAll);
return () => {
api.off(STORIES_COLLAPSE_ALL, collapseAll);
};
}, [api, collapseAll]);
/code/core/src/manager/container/Menu.tsx /code/core/src/manager/components/sidebar/useExpanded.ts
Describe the bug
The "collapse all" action is broken. It logs an error in the console:
Reproduction link
https://635781f3500dd2c49e189caf-hyyihpyiuz.chromatic.com
Reproduction steps
System
Additional context
No response