Skip to content

feat: add setting to hide subtasks from task list root#1969

Open
Spencerduran wants to merge 1 commit into
callumalpass:mainfrom
Spencerduran:feat/hide-root-subtasks-setting
Open

feat: add setting to hide subtasks from task list root#1969
Spencerduran wants to merge 1 commit into
callumalpass:mainfrom
Spencerduran:feat/hide-root-subtasks-setting

Conversation

@Spencerduran
Copy link
Copy Markdown

Summary

Closes #1715

Adds a "Hide subtasks in list root" toggle in Settings → Appearance (alongside the existing expandable subtasks options). When enabled, tasks that belong to a parent project are hidden from the root level of task list views — they remain visible only when their parent task is expanded.

Implementation

Pure CSS, no JS-level deduplication required. The feature works by toggling a tasknotes-hide-root-subtasks class on document.body, which activates this rule in task-list-view.css:

```css
body.tasknotes-hide-root-subtasks .tasknotes-plugin
.task-card:has(.task-card__project-link):not(:has(.task-card__subtasks)):not(.task-card__subtasks .task-card) {
display: none;
}
```

The three-part selector:

  • :has(.task-card__project-link) — matches tasks that belong to a parent
  • :not(:has(.task-card__subtasks)) — excludes expanded parent tasks (which have a subtasks container), preventing them from being hidden
  • :not(.task-card__subtasks .task-card) — excludes subtasks already nested under an expanded parent, so they still show in the fold-out

Changes

  • src/types/settings.ts — adds hideRootSubtasks: boolean
  • src/settings/defaults.ts — defaults to false (opt-in)
  • src/settings/tabs/appearanceTab.ts — adds toggle with body class side-effect
  • src/main.ts — applies/removes body class on load/unload
  • src/i18n/resources/en.ts — adds English strings
  • styles/task-list-view.css — adds the CSS rule

Test plan

  • Enable the setting — subtasks at root level disappear
  • Expand a parent task — subtasks appear in the fold-out as expected
  • Collapse the parent — subtasks return to hidden
  • Disable the setting — root-level subtasks reappear
  • Reload Obsidian with setting enabled — body class applied on startup, subtasks hidden immediately

@Spencerduran
Copy link
Copy Markdown
Author

Just noticed #1792 tackles the same problem with a JS-based approach. It filters subtasks before rendering by checking whether each task's parent is in the current result set, so subtasks stay visible when their parent is filtered out. This PR is a global CSS toggle with no per-view config and no awareness of whether the parent is in the view.

Happy to close this if you'd prefer #1792.

Adds a "Hide subtasks in list root" toggle in Settings → Appearance.
When enabled, tasks that belong to a parent project are hidden from the
root level of task list views. They remain visible when their parent is
expanded via the subtask chevron.

Implemented as a pure CSS rule gated on a body class
(tasknotes-hide-root-subtasks), which distinguishes root-level subtasks
from nested ones using :has(.task-card__project-link) combined with
:not(:has(.task-card__subtasks)) to avoid hiding expanded parent tasks.

Closes callumalpass#1715
@Spencerduran Spencerduran force-pushed the feat/hide-root-subtasks-setting branch from fefd8ef to 213fe6e Compare May 29, 2026 21:57
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.

[FR]: Hide subtasks when they're folded under Main Task

1 participant