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