Skip to content

Fix subdirectories not displaying recursively in file explorer sidebar - #33

Merged
Tkaixiang merged 2 commits into
Tkaixiang:fix/mikejoseph23-subdirectory-renderingfrom
mikejoseph23:fix/subdirectory-rendering
Dec 13, 2025
Merged

Tkaixiang merged 2 commits into
Tkaixiang:fix/mikejoseph23-subdirectory-renderingfrom
mikejoseph23:fix/subdirectory-rendering

Conversation

@mikejoseph23

Copy link
Copy Markdown

Fixes #26

Problem

Subdirectories are not displaying recursively in the file explorer sidebar. Only the first level of folders is expandable, but any sub-folders underneath are not listed even though they exist in the filesystem.

Root Cause

The folder tree rendering logic in treeFolder.vue wasn't properly handling nested folder structures. The recursive folder component wasn't being invoked for child folders.

Solution

Fixed the recursive folder rendering:

  • Updated treeFolder.vue to properly render child folders recursively
  • Adjusted the folder expansion/collapse logic to handle nested structures
  • Added proper depth tracking for nested folder indentation

Additional Changes

  • Added 20px bottom padding to <ul> elements in rendered markdown for better readability

Testing

Tested on macOS with deeply nested folder structures. All subdirectories now display correctly and can be expanded/collapsed as expected.

Files Changed

  • src/renderer/src/components/sideBar/treeFolder.vue - Fixed recursive folder rendering
  • src/renderer/src/components/sideBar/tree.vue - Updated folder tree structure
  • src/renderer/src/store/project.js - Fixed directory handling logic
  • src/renderer/src/store/treeCtrl.js - Improved tree control
  • src/muya/themes/default.css - Added ul padding
  • static/themes/default.css - Added ul padding

This commit fixes a critical bug where subdirectories were not appearing
in the file explorer sidebar when expanding folders, while files displayed
correctly.

Changes:
- Add missing self-import to treeFolder.vue for recursive rendering
  (Vue 3 script setup requires explicit imports including self-references)
- Use local reactive state for isCollapsed to properly track folder
  expansion state
- Change v-if to v-show for folder-contents to maintain DOM presence
- Use proper v-for keys based on item IDs instead of array indexes
- Implement alphabetical sorting for folders in addDirectory
- Add event buffering for directory changes before tree initialization
- Extract _processTreeEvent method for cleaner event handling

Root cause: The recursive Folder component was referenced in the template
as <folder> but was never imported in the script setup section, causing
Vue to fail silently when trying to render nested folder components.

Testing: Verified that subdirectories now render correctly when expanding
folders in the sidebar, while maintaining proper file display and folder
state persistence.

@Tkaixiang Tkaixiang left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR :), left some comments mainly regarding code quality/performance concerns

Comment on lines +27 to +33
<div v-show="!isCollapsed" class="folder-contents">
<Folder
v-for="childFolder of folder.folders"
:key="childFolder.id"
:folder="childFolder"
:depth="depth + 1"
></folder>
></Folder>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why v-show was used over v-if? This means the entire tree is rendered at any-time instead of conditional rendering, which can cause lag for big folders

Comment on lines 83 to 111
@@ -89,7 +94,7 @@ const handleInputFocus = () => {
input.value.focus()
createName.value = ''
if (props.folder) {
// eslint-disable-next-line vue/no-mutating-props
isCollapsed.value = false
props.folder.isCollapsed = false
}
}
@@ -101,8 +106,8 @@ const handleInputEnter = () => {
}

const folderNameClick = () => {
// eslint-disable-next-line vue/no-mutating-props
props.folder.isCollapsed = !props.folder.isCollapsed
isCollapsed.value = !isCollapsed.value
props.folder.isCollapsed = isCollapsed.value
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are using a local reactive variable to track the collapsible state (which is good), shouldn't we remove the props.folder.isCollapsed mutation then?

import bus from '../../bus'
import File from './treeFile.vue'
// Import self for recursive rendering
import Folder from './treeFolder.vue'

@Tkaixiang Tkaixiang Dec 11, 2025 •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think you need to import itself? It is more of we need to change the name to <tree-folder> if we want to still use TreeFolder

Comment thread static/themes/default.css
@media not print {
#ag-editor-id {
max-width: var(--editorAreaWidth);
max-width: 100%;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for this change? it seems unrelated to this PR, and causes the editor to stretch out to the entire screen on ultra wide monitors.

@media not print {
#ag-editor-id {
max-width: var(--editorAreaWidth);
max-width: 100%;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for this change? it seems unrelated to this PR, and causes the editor to stretch out to the entire screen on ultra wide monitors. [Same as below for the .css file comment]

@Tkaixiang
Tkaixiang changed the base branch from trunk to fix/mikejoseph23-subdirectory-rendering December 13, 2025 04:11
@Tkaixiang

Copy link
Copy Markdown
Owner

Will be taking this PR in for fixes in a seperate branch first before merging into trunk. Thank you for it :)

@Tkaixiang
Tkaixiang merged commit 6cfb252 into Tkaixiang:fix/mikejoseph23-subdirectory-rendering Dec 13, 2025
@mikejoseph23

Copy link
Copy Markdown
Author

You're welcome. Sorry I didn't reply sooner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Subdirectories not displaying in file explorer sidebar

2 participants