mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
fix(topic): Topic list keybind (#181)
* fix(page): improve keybind * fix(topic): improve keybind * fix: learning state selector
This commit is contained in:
@@ -1,35 +1,13 @@
|
||||
"use client"
|
||||
|
||||
import { useCallback, useEffect, useState } from "react"
|
||||
import { TopicHeader } from "./header"
|
||||
import { TopicList } from "./list"
|
||||
import { useAtom } from "jotai"
|
||||
import { commandPaletteOpenAtom } from "@/components/custom/command-palette/command-palette"
|
||||
|
||||
export function TopicRoute() {
|
||||
const [activeItemIndex, setActiveItemIndex] = useState<number | null>(null)
|
||||
const [isCommandPaletteOpen] = useAtom(commandPaletteOpenAtom)
|
||||
const [disableEnterKey, setDisableEnterKey] = useState(false)
|
||||
|
||||
const handleCommandPaletteClose = useCallback(() => {
|
||||
setDisableEnterKey(true)
|
||||
setTimeout(() => setDisableEnterKey(false), 100)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isCommandPaletteOpen) {
|
||||
handleCommandPaletteClose()
|
||||
}
|
||||
}, [isCommandPaletteOpen, handleCommandPaletteClose])
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-auto flex-col overflow-hidden">
|
||||
<TopicHeader />
|
||||
<TopicList
|
||||
activeItemIndex={activeItemIndex}
|
||||
setActiveItemIndex={setActiveItemIndex}
|
||||
disableEnterKey={disableEnterKey}
|
||||
/>
|
||||
<TopicList />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user