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:
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user