Fix calendar popup ignoring reminder-format settings and migrate the hotkey chooser to CM6#337
Merged
Merged
Conversation
show-date-chooser (used by the "Show date chooser" command/hotkey) still built the legacy CM5 DateTimeChooserView, whose charCoords()/ defaultTextHeight() calls don't exist on Obsidian's current CM6 EditorView. In Live Preview this threw on every invocation and was silently swallowed, falling back to the plain Modal chooser instead of the intended inline popup — the same CM5-incompatibility already fixed for the inline "(@" trigger in cm6-datetime-chooser.ts (added alongside editor-extension.ts). Reuse that same CM6DateTimeChooserPopup for the hotkey path and remove the now-unreferenced CM5 view. Fixes #248
Calendar.svelte constructed its own `new Settings()` just to read the week-start value. The Settings constructor ended with a global side effect — it installed a config bound to that fresh, never-loaded instance via `setReminderFormatConfig()` — so every time the date/time chooser was mounted, all reminder-format settings (e.g. `useCustomEmojiForTasksPlugin`) silently reverted to their defaults for the rest of the session. This, not the CM5-era popup code, was the root cause of the "settings are not reflected" half of #248, and it affected the `(@` trigger and reminder-pill paths as well. - Calendar.svelte now takes `weekStart` as a prop, passed down from all three chooser entry points (hotkey command, `(@` trigger, reminder pill). This also makes the calendar honor the user's actual week-start setting, which the stray default-valued instance never did. - The config-installation block is extracted out of the Settings constructor into an explicit `wireReminderFormatConfig()` called once by PluginData, so constructing a Settings instance no longer has process-wide side effects. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
uphy
force-pushed
the
worktree-fix-hotkey-datetime-chooser-cm6
branch
from
July 12, 2026 15:32
52f24bd to
b58a7b1
Compare
The week-start offset was applied twice: the settings tab mutated the bundled moment's locale (`moment.updateLocale` with the configured `dow`), and the calendar then added the explicit `weekStart` offset on top of the locale-relative `.weekday()`. With "Week start: Monday" the calendar therefore rendered starting on Tuesday. The double application had been masked while the calendar's weekStart was always the stray default (0). All calendar math now uses the absolute, locale-independent `.day()` (0=Sunday) together with the explicit `weekStart` value, and the `moment.updateLocale` side effect is removed — nothing depends on the locale's `dow` anymore, and it only ever ran while the settings tab was open, making behavior state-dependent. Weekend highlighting is now an absolute Sat/Sun check, unchanged for the default locale. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Closes #248
Root cause
Calendar.svelteconstructed its ownnew Settings()just to read the week-start value. TheSettingsconstructor ended with a global side effect: it installed a reminder-format config bound to that fresh, never-loaded instance viasetReminderFormatConfig(). As a result, every time the date/time chooser was mounted, all reminder-format settings (e.g.useCustomEmojiForTasksPlugin,useReminderTimeFallbackForTasksPlugin) silently reverted to their defaults for the rest of the session — which is why reminders inserted from the calendar popup came out as📅 2026-07-20instead of⏰ 2026-07-20 09:15 📅 2026-07-20 09:15. This affected the hotkey command, the(@trigger, and the reminder-pill edit path alike.The CM5-era popup code was a separate, secondary problem: the hotkey command still used the old
DateTimeChooserView, which throws on CM6 (charCoords/defaultTextHeight) and silently fell back to the center modal.Changes
AutoComplete.show()now uses the sameCM6DateTimeChooserPopupas the(@trigger (PR Show date/time chooser inline near the cursor in Live Preview #307) instead of the CM5-onlyDateTimeChooserView(deleted), removing the exception → modal fallback.Calendar.sveltetakesweekStartas a prop, passed down from all three chooser entry points.Settingsconstructor into an explicitwireReminderFormatConfig()called once byPluginData, so constructing aSettingsinstance no longer has process-wide side effects.dow, and the calendar added the explicitweekStarton top of locale-relative.weekday()), so "Week start: Monday" rendered a Tuesday-first calendar. All calendar math now uses the absolute.day()plus the explicitweekStart, and themoment.updateLocaleside effect is removed. Weekend highlighting is an absolute Sat/Sun check, unchanged for the default locale. Covered by new unit tests insrc/ui/calendar.test.ts.Verification
mise run pre-commit: lint/typecheck/svelte-check clean; all tests pass except the pre-existing date-boundary flaky insrc/model/reminder.test.ts(unrelated).useCustomEmojiForTasksPlugin+useReminderTimeFallbackForTasksPluginenabled and Tasks as the primary format, both the hotkey command and the(@trigger now open the inline popup near the cursor and insert⏰ <date> <time> 📅 <date> <time>as configured. Before the fix, both inserted📅 <date>only.🤖 Generated with Claude Code