Skip to content

Fix embed command ignoring defaultFolder destination setting - #205

Open
bberak wants to merge 1 commit into
tldraw:mainfrom
bberak:fix/embed-default-folder
Open

Fix embed command ignoring defaultFolder destination setting#205
bberak wants to merge 1 commit into
tldraw:mainfrom
bberak:fix/embed-default-folder

Conversation

@bberak

@bberak bberak commented Apr 26, 2026

Copy link
Copy Markdown

Summary

🚨NOTE: This PR (including code) was created with Claude Code.

  • When creating a new drawing via the / embed command, attachTo is always set to the current file. The condition (attachTo || destinationMethod === 'attachments-folder') in getTldrawFileDestination therefore always short-circuits to true, causing the file to be saved to Obsidian's core attachmentFolderPath regardless of the plugin's destinationMethod setting.
  • 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 direct switch on destinationMethod, so attachTo no longer overrides the configured destination.

Steps to reproduce

  1. Set destinationMethod to "default-folder" and defaultFolder to any folder (e.g. "Drawings")
  2. Set confirmDestination to false
  3. Set Obsidian's core attachmentFolderPath to a different folder (e.g. "Attachments")
  4. Open a note and use the / slash command to embed a new tldraw drawing
  5. Expected: file is created in "Drawings"
  6. Actual: file is created in "Attachments"

Note: when confirmDestination is true, the confirmation modal works correctly because it builds the destination list independently without the attachTo short-circuit.

Test plan

  • Verify embed command respects defaultFolder when destinationMethod is "default-folder" and confirmDestination is false
  • Verify embed command still uses Obsidian's attachment folder when destinationMethod is "attachments-folder"
  • Verify colocate mode still works for embed commands
  • Verify non-embed "create new drawing" commands still work correctly
  • Verify confirmDestination: true still works as before

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>
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.

1 participant