Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions frontend/src/views/TreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@

// Autosave the view document.
const firstSave = useRef(true)
const saveTimer = useRef<number>()
// React 19's types dropped the zero-argument useRef overload, so the timer
// id starts as an explicit undefined instead.
const saveTimer = useRef<number | undefined>(undefined)
const saveNow = useCallback(() => {
const doc: TreeViewDoc = {
version: 1,
Expand Down Expand Up @@ -228,7 +230,7 @@
el.addEventListener('wheel', onWheel, { passive: false })
return () => el.removeEventListener('wheel', onWheel)
}, [])
const scrollTimer = useRef<number>()
const scrollTimer = useRef<number | undefined>(undefined)
const onScroll = () => {
const el = scrollRef.current
if (!el) return
Expand Down Expand Up @@ -307,21 +309,21 @@
}

useEffect(() => {
const onKey = (e: KeyboardEvent) => {
const t = e.target as HTMLElement
if (t && (t.tagName === 'INPUT' || t.tagName === 'SELECT' || t.tagName === 'TEXTAREA')) return
const mod = e.ctrlKey || e.metaKey
if (mod && e.key.toLowerCase() === 'z' && !e.shiftKey) { e.preventDefault(); undo() }
else if (mod && (e.key.toLowerCase() === 'y' || (e.key.toLowerCase() === 'z' && e.shiftKey))) { e.preventDefault(); redoOne() }
else if (!mod && selected) {
if (e.key === 'c') toggleCollapse(selected)
else if (e.key === 'r') reroot(selected)
else if (e.key === 'o' && selected.tipKey === null) push({ op: 'rotate', clade: selected.clade })
else if (e.key === 'F2') { e.preventDefault(); startRename(selected) }
else if (e.key === 'Escape') setSelClade(null)
else if (e.key === 'ArrowUp' && selected.parent) { e.preventDefault(); setSelClade(selected.parent.clade) }
}
}

Check notice on line 326 in frontend/src/views/TreeView.tsx

View check run for this annotation

codefactor.io / CodeFactor

frontend/src/views/TreeView.tsx#L312-L326

Complex Method
window.addEventListener('keydown', onKey)
return () => window.removeEventListener('keydown', onKey)
}, [undo, redoOne, selected, toggleCollapse, reroot, startRename, push])
Expand Down
6 changes: 3 additions & 3 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export default defineConfig({
sourcemap: false,
rollupOptions: {
output: {
manualChunks: {
plotly: ['plotly.js-dist-min'],
},
// vite 8 (rolldown) took only the function form; the old object form
// died at "manualChunks is not a function".
manualChunks: (id: string) => (id.includes('plotly.js-dist-min') ? 'plotly' : undefined),
},
},
},
Expand Down
Loading