fix: handle nested folder click with endsWith match
This commit is contained in:
@@ -106,8 +106,9 @@ export const ApiDocViewer = ({ onDocsPathChange, showAddModal, onCloseAddModal }
|
|||||||
}, [externalDocs])
|
}, [externalDocs])
|
||||||
|
|
||||||
const handleFolderClick = useCallback((folderPath: string) => {
|
const handleFolderClick = useCallback((folderPath: string) => {
|
||||||
const sameNamePath = `${folderPath}/${folderPath}.md`
|
const sameNameDoc = externalDocs.find(d =>
|
||||||
const sameNameDoc = externalDocs.find(d => d.relativePath === sameNamePath)
|
d.relativePath.endsWith(`/${folderPath}.md`)
|
||||||
|
)
|
||||||
|
|
||||||
if (sameNameDoc) {
|
if (sameNameDoc) {
|
||||||
setSelectedPath(sameNameDoc.relativePath.replace(/^api\//, ''))
|
setSelectedPath(sameNameDoc.relativePath.replace(/^api\//, ''))
|
||||||
|
|||||||
Reference in New Issue
Block a user