Repository navigation
fix(bases): use isEmpty() for generated emptiness checks (#2524) - #2525
Merged
Merged
Conversation
In Bases, `!prop` and `list(prop).length` evaluate to null when a property is missing or blank, so trackingStatus never returned "Not started" for tasks without time entries. Use isEmpty() in trackingStatus and timeEstimateCategory, and in the saved-view exporter's empty-list filter.
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.
Fixes #2524 (reported by @dsebastien).
Problem
In Obsidian Bases,
!propandlist(prop).lengthevaluate to null (not true / 0) when the property is missing or blank. The generatedtrackingStatusformula used!time_entries || list(time_entries).length == 0, so tasks without atime_entriesproperty never showed "Not started".Changes
src/templates/defaultBasesFiles.ts:trackingStatusnow usestime_entries.isEmpty(). The "No estimate" test intrackingStatusandtimeEstimateCategoryis nowtimeEstimate.isEmpty() || timeEstimate == 0. That test already worked because of its== nullfallback; it now uses the same form as the other checks. Neither property is a checkbox, soisEmpty()is safe here.src/services/BasesFilterConverter.ts: the saved-view exporter turned "is []" into(!prop || prop.length == 0), which had the same bug. It now producesprop.isEmpty(). The array branch only handles list values; booleans are handled elsewhere.default-base-templates.mdshowed the broken forms, includingprojectCount/contextCount, which the generator no longer uses. Updated to the new forms.Existing vaults
TaskNotes does not migrate existing
.basefiles. On startupensureDefaultBasesViewFilesonly creates missing files. Overwriting is opt-in, through Settings → Views & base files → Update files or the Update default base files command, and it replaces manual edits. So existing users keep the old formula until they use Update files or edittrackingStatusby hand. The release note covers both options.Testing
tests/unit/issues/issue-2524-tracking-status-isempty.test.tschecks the generated formula text, checks that no generated formula uses!prop ||, and checks the exporter. It fails onmainand passes here.e2e/issues/issue-2524-tracking-status-isempty.spec.tsbuilds a table base over notes with entries/estimate missing, null,[]/0, and set. The old entries formula gives "some" for the missing and null cases;isEmpty()gives "none". The new estimate test gives the same results as the old one.npm run lint,typecheck,npm test(6058 passed; one earlier run had a single failure that did not reproduce on rerun),i18n:check,docs:check,build,check:bundle-size.