Skip to content

fix:Save card on lost focus if not empty#1151

Open
codingseb wants to merge 5 commits into
obsidian-community:mainfrom
codingseb:main
Open

fix:Save card on lost focus if not empty#1151
codingseb wants to merge 5 commits into
obsidian-community:mainfrom
codingseb:main

Conversation

@codingseb
Copy link
Copy Markdown

@codingseb codingseb commented Aug 11, 2025

Corrections

Correct #1149, #1123, #1091 and #1100 behavior.

New behaviors when click outside a new card:

  • if content is empty cancel the card
  • if content is not empty validate the card to not lose it

New behavior when click outside a card in edition :

  • Validate the edition to not lose the work done in the card if the note change.

This should avoid a lot of frustration

Tests

I tested it on my vault and it works well.

@codingseb codingseb changed the title Save card on lost focus if not empty fix:Save card on lost focus if not empty Aug 11, 2025
@lucaskuzma
Copy link
Copy Markdown

lucaskuzma commented Oct 23, 2025

Please merge! 😬🙏 @mgmeyers

@rscircus
Copy link
Copy Markdown

Hi, I run into this daily. How can I help to get this merged, @mgmeyers?

@rscircus
Copy link
Copy Markdown

@codingseb - I'll test it on my vault and add the results in this comment today. That's the least thing I can do for helping on the robustness side. Let me know if you need a second pair of eyes for the rest of the process here. :)

@rscircus
Copy link
Copy Markdown

npm complains that there exist 18 vulnerabilities. However, I think this concerns the plugin in general...

r@R-Pro~/R/obsidian-kanban-codingseb>npm install                                                                                                                                 main
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm warn gitignore-fallback No .npmignore file found, using .gitignore for file exclusion. Consider creating a .npmignore file to explicitly control published files.
npm warn deprecated @oclif/errors@1.3.5: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm warn deprecated @oclif/help@1.0.1: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
npm warn deprecated @oclif/parser@3.8.7: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated @oclif/command@1.8.16: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead
npm warn deprecated @oclif/config@1.18.3: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated mdast@3.0.0: `mdast` was renamed to `remark`
npm warn deprecated @oclif/config@1.18.2: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated @oclif/config@1.18.2: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.
npm warn deprecated eslint@8.57.0: This version is no longer supported. Please see https://eslint.org/version-support for other options.

added 599 packages, and audited 600 packages in 33s

168 packages are looking for funding
  run `npm fund` for details

18 vulnerabilities (1 low, 13 moderate, 4 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.

@rscircus
Copy link
Copy Markdown

Sorry, @codingseb, but I actually found an issue here.

So, the contents get preserved when I click somewhere else in the kanban. Which is great.

However, it gets lost when I click a link and the tab loads the underlying markdown file. When I navigate back the card is not present. But, it is present when I click somewhere randomly else first - this actually happened by accident :-) but helped me to reproduce that.

Note, that I have vim-mode enabled.

Implements a global save mechanism to persist edits
before a Kanban view is closed or a tab is changed.

This ensures no data loss by triggering a 'save-all-editing-items'
event, which is listened for by both ItemContent and ItemForm
components to save any pending changes.
@codingseb
Copy link
Copy Markdown
Author

codingseb commented Jan 12, 2026

Thanks @rscircus

I added some triggers to save modifications and creations on :

  • plugin unload (to manage when obsidian is closing)
  • tab close
  • whenever the note changes in current tab.

That should handle more cases.

@codingseb
Copy link
Copy Markdown
Author

codingseb commented Jan 12, 2026

main.js (obsolete corrected version for enabling menu items below)
here is the corrected version of the file to replace in your plugin folder. For people that do not want to wait on the merge.
Otherwise you can fork clone and checkout my fork to npm run build yourself

@talperets
Copy link
Copy Markdown

Hi! I just wanted to say I’m also running into this issue on a daily basis, so I’d really love to see this merged.

Is there anything I can do to help move this forward — testing, reviewing, or providing additional feedback? Happy to contribute if it helps!

@gpanakkal
Copy link
Copy Markdown

Would really love to have this feature! It would also be nice to add a setting for this so that users who prefer to cancel changes aren't affected.

@NicholasDawson
Copy link
Copy Markdown

I have been using the fixed version for a while now, and mostly everything works well (especially glad to not be losing progress/work anymore!!)

I did notice that right click actions like spelling corrections do not work since any click closes and saves the note (see screen recording below)

Obsidian_Z5hbAicuDv.mp4

Previously, clicking on menu elements (e.g., dropdowns, context menus) associated with an item could erroneously trigger the `useOnclickOutside` handler. This could lead to premature saving or cancellation of an item's editing state.

By adding `menu` and `menu-item` to the `ignoreClass` list for the `useOnclickOutside` hook, these interactions are now correctly disregarded, ensuring a smoother user experience.
@codingseb
Copy link
Copy Markdown
Author

codingseb commented May 19, 2026

I have been using the fixed version for a while now, and mostly everything works well (especially glad to not be losing progress/work anymore!!)

I did notice that right click actions like spelling corrections do not work since any click closes and saves the note (see screen recording below)

Obsidian_Z5hbAicuDv.mp4

Thanks @NicholasDawson I didn't notice that. I added menu-items in exceptions for card validation.

Here is the corrected compiled version
main.js

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.

6 participants