Skip to content

Open-source and local-first Slack and Notion alternative that puts you in control of your data

Fix a bug with reordering of nodes using .reverse()

Hakan Shehu76219f0d8943
diff --git a/apps/desktop/src/main/handlers/queries/node-with-ancestors-get.ts b/apps/desktop/src/main/handlers/queries/node-with-ancestors-get.ts
index 97299a6e..57e73b01 100644
--- a/apps/desktop/src/main/handlers/queries/node-with-ancestors-get.ts
+++ b/apps/desktop/src/main/handlers/queries/node-with-ancestors-get.ts
@@ -83,7 +83,7 @@ export class NodeWithAncestorsGetQueryHandler
}
while (node) {
- result.push(node);
+ result.unshift(node);
node = rows.find((row) => row.id === node?.parent_id);
if (!node || node.id === node.parent_id) {
@@ -91,6 +91,6 @@ export class NodeWithAncestorsGetQueryHandler
}
}
- return result.reverse();
+ return result;
}
}
diff --git a/apps/desktop/src/renderer/components/collaborators/node-collaborators.tsx b/apps/desktop/src/renderer/components/collaborators/node-collaborators.tsx
index fea18041..b5fdb1a1 100644
--- a/apps/desktop/src/renderer/components/collaborators/node-collaborators.tsx
+++ b/apps/desktop/src/renderer/components/collaborators/node-collaborators.tsx
@@ -30,7 +30,7 @@ export const NodeCollaborators = ({
);
const isAdmin = hasAdminAccess(role);
- const ancestors = nodes.reverse().filter((node) => node.id !== nodeId);
+ const ancestors = nodes.filter((node) => node.id !== nodeId);
return (
<div className="flex flex-col gap-2">
diff --git a/apps/desktop/src/renderer/components/layouts/layout-modal.tsx b/apps/desktop/src/renderer/components/layouts/layout-modal.tsx
index 818b799e..14ec92dc 100644
--- a/apps/desktop/src/renderer/components/layouts/layout-modal.tsx
+++ b/apps/desktop/src/renderer/components/layouts/layout-modal.tsx
@@ -1,8 +1,13 @@
import React from 'react';
-import { Dialog, DialogContent } from '@/renderer/components/ui/dialog';
+import {
+ Dialog,
+ DialogContent,
+ DialogTitle,
+} from '@/renderer/components/ui/dialog';
import { ContainerContext } from '@/renderer/contexts/container';
import { NodeContainer } from '@/renderer/components/layouts/node-container';
import { useWorkspace } from '@/renderer/contexts/workspace';
+import { VisuallyHidden } from '@radix-ui/react-visually-hidden';
interface LayoutModalProps {
nodeId: string;
@@ -29,6 +34,9 @@ export const LayoutModal = ({ nodeId }: LayoutModalProps) => {
className="flex h-[calc(100vh-100px)] max-h-full w-8/12 max-w-full flex-col gap-1 overflow-hidden px-0.5 pt-0 md:w-8/12"
aria-describedby={undefined}
>
+ <VisuallyHidden>
+ <DialogTitle>Modal</DialogTitle>
+ </VisuallyHidden>
<ContainerContext.Provider value={{ nodeId, mode: 'modal' }}>
<NodeContainer nodeId={nodeId} />
</ContainerContext.Provider>
diff --git a/apps/desktop/src/renderer/components/records/record-container.tsx b/apps/desktop/src/renderer/components/records/record-container.tsx
index e97710d1..cc1d66c2 100644
--- a/apps/desktop/src/renderer/components/records/record-container.tsx
+++ b/apps/desktop/src/renderer/components/records/record-container.tsx
@@ -41,7 +41,10 @@ export const RecordContainer = ({ nodeId }: RecordContainerProps) => {
const databaseAncestors = nodes.slice(0, databaseIndex);
const recordRole = extractNodeRole(nodes, workspace.userId);
- const databaseRole = extractNodeRole(databaseAncestors, workspace.userId);
+ const databaseRole = extractNodeRole(
+ [...databaseAncestors, database],
+ workspace.userId
+ );
if (!recordRole || !databaseRole) {
return null;