feat: add setting to hide subtasks from task list root#1969
Open
Spencerduran wants to merge 1 commit into
Open
feat: add setting to hide subtasks from task list root#1969Spencerduran wants to merge 1 commit into
Spencerduran wants to merge 1 commit into
Conversation
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
fefd8ef to
213fe6e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-subtasksclass ondocument.body, which activates this rule intask-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-outChanges
src/types/settings.ts— addshideRootSubtasks: booleansrc/settings/defaults.ts— defaults tofalse(opt-in)src/settings/tabs/appearanceTab.ts— adds toggle with body class side-effectsrc/main.ts— applies/removes body class on load/unloadsrc/i18n/resources/en.ts— adds English stringsstyles/task-list-view.css— adds the CSS ruleTest plan