ux: improvements to keyboard navigation

This commit is contained in:
Alejandro Gómez
2025-12-18 16:14:56 +01:00
parent a6650ff6e1
commit 967f1eb89b
2 changed files with 53 additions and 6 deletions

View File

@@ -142,6 +142,32 @@ export const useGrimoire = () => {
});
}, [setState]);
const createWorkspaceWithNumber = useCallback(
(number: number) => {
setState((prev) => {
// Check if we're leaving an empty workspace and should auto-remove it
const currentWorkspace = prev.workspaces[prev.activeWorkspaceId];
const shouldDeleteCurrent =
currentWorkspace &&
currentWorkspace.windowIds.length === 0 &&
Object.keys(prev.workspaces).length > 1;
if (shouldDeleteCurrent) {
// Delete the empty workspace, then create new one
const afterDelete = Logic.deleteWorkspace(
prev,
prev.activeWorkspaceId,
);
return Logic.createWorkspace(afterDelete, number);
}
// Normal workspace creation
return Logic.createWorkspace(prev, number);
});
},
[setState],
);
const addWindow = useCallback(
(appId: AppId, props: any, commandString?: string, customTitle?: string) =>
setState((prev) =>
@@ -250,6 +276,7 @@ export const useGrimoire = () => {
locale: state.locale || browserLocale,
activeWorkspace: state.workspaces[state.activeWorkspaceId],
createWorkspace,
createWorkspaceWithNumber,
addWindow,
updateWindow,
removeWindow,