Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(ui): cursor placement and text selection broken mid-sentence (#3926)

Harsh Kumar01388fbf71ff
diff --git a/apps/screenpipe-app-tauri/app/layout.tsx b/apps/screenpipe-app-tauri/app/layout.tsx
index 77f98310c..d3980b80f 100644
--- a/apps/screenpipe-app-tauri/app/layout.tsx
+++ b/apps/screenpipe-app-tauri/app/layout.tsx
@@ -318,8 +318,11 @@ export default function RootLayout({
const SELECTABLE =
'.prose, .selectable-text-layer, input, textarea, [contenteditable="true"], [contenteditable=""]';
const onSelectStart = (e: Event) => {
- const target = e.target as Element | null;
- if (target?.closest?.(SELECTABLE)) return; // allow selecting real content
+ // e.target may be a Text node (when clicking mid-text), which lacks
+ // .closest(). Walk up to the nearest Element so the check works.
+ const node = e.target as Node | null;
+ const el = node instanceof Element ? node : node?.parentElement;
+ if (el?.closest?.(SELECTABLE)) return; // allow selecting real content
e.preventDefault();
};
document.addEventListener("selectstart", onSelectStart);