Fix embed command ignoring defaultFolder destination setting - #205
Open
bberak wants to merge 1 commit into
Open
Conversation
When creating a new drawing via the "/" embed command, `attachTo` is always set to the current file. The condition `(attachTo || destinationMethod === 'attachments-folder')` therefore always evaluates to true, causing the file to be saved to Obsidian's core `attachmentFolderPath` regardless of the plugin's `destinationMethod` setting. This means users who set `destinationMethod` to `"default-folder"` (e.g. "Drawings") have their preference silently ignored for embed commands — files end up in the vault's attachment folder instead. The fix replaces the short-circuiting `if` with a proper `switch` on `destinationMethod`, so `attachTo` no longer overrides the configured destination. The `attachTo` parameter is still passed through to `getAttachmentsFolder` when `destinationMethod` is explicitly `"attachments-folder"`. Co-Authored-By: Claude Opus 4.6 (1M context) <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.
Summary
/embed command,attachTois always set to the current file. The condition(attachTo || destinationMethod === 'attachments-folder')ingetTldrawFileDestinationtherefore always short-circuits totrue, causing the file to be saved to Obsidian's coreattachmentFolderPathregardless of the plugin'sdestinationMethodsetting.destinationMethodto"default-folder"(e.g."Drawings") have their preference silently ignored for embed commands — files end up in the vault's attachment folder instead.ifwith a directswitchondestinationMethod, soattachTono longer overrides the configured destination.Steps to reproduce
destinationMethodto"default-folder"anddefaultFolderto any folder (e.g."Drawings")confirmDestinationtofalseattachmentFolderPathto a different folder (e.g."Attachments")/slash command to embed a new tldraw drawing"Drawings""Attachments"Note: when
confirmDestinationistrue, the confirmation modal works correctly because it builds the destination list independently without theattachToshort-circuit.Test plan
defaultFolderwhendestinationMethodis"default-folder"andconfirmDestinationisfalsedestinationMethodis"attachments-folder"confirmDestination: truestill works as before