Fix duplicate tabs on drag-and-drop and long URL overflow

Guard against Windows/WebView2 firing duplicate drop events by
tracking in-progress paths with a Set ref. Add overflow-wrap and
word-break to markdown content so long unbroken strings wrap.
This commit is contained in:
Your Name
2026-02-19 22:00:51 +02:00
parent 766f0f94f2
commit 5af64df152
2 changed files with 9 additions and 1 deletions

View File

@@ -599,6 +599,7 @@ function App() {
}, [updateTabScrollState]); }, [updateTabScrollState]);
// Tauri native drag-and-drop (bypasses browser event interception) // Tauri native drag-and-drop (bypasses browser event interception)
const pendingDropPaths = useRef<Set<string>>(new Set());
useEffect(() => { useEffect(() => {
let unlisten: (() => void) | undefined; let unlisten: (() => void) | undefined;
getCurrentWebview().onDragDropEvent(async (event) => { getCurrentWebview().onDragDropEvent(async (event) => {
@@ -611,6 +612,9 @@ function App() {
const paths = event.payload.paths; const paths = event.payload.paths;
const mdPath = paths.find((p: string) => p.endsWith('.md') || p.endsWith('.markdown') || p.endsWith('.txt')); const mdPath = paths.find((p: string) => p.endsWith('.md') || p.endsWith('.markdown') || p.endsWith('.txt'));
if (mdPath) { if (mdPath) {
// Guard against duplicate drop events (Windows/WebView2 fires twice)
if (pendingDropPaths.current.has(mdPath)) return;
pendingDropPaths.current.add(mdPath);
try { try {
const existing = tabsRef.current.find(t => t.path === mdPath); const existing = tabsRef.current.find(t => t.path === mdPath);
if (existing) { if (existing) {
@@ -628,6 +632,8 @@ function App() {
} }
} catch (err) { } catch (err) {
console.error('Failed to read dropped file:', err); console.error('Failed to read dropped file:', err);
} finally {
pendingDropPaths.current.delete(mdPath);
} }
} }
} }

View File

@@ -1173,6 +1173,8 @@ html, body, #root {
max-width: 680px; max-width: 680px;
margin: 0 auto; margin: 0 auto;
color: var(--color-text-primary); color: var(--color-text-primary);
overflow-wrap: break-word;
word-break: break-word;
/* Premium typography settings */ /* Premium typography settings */
font-size: 17px; font-size: 17px;