danielo515 / obsidian-modal-form

Define forms for filling data that you will be able to open from anywhere you can run JS
https://danielorodriguez.com/obsidian-modal-form/
MIT License
187 stars 15 forks source link

[BUG] Submitting a form does not close the form. #232

Open Tempystral opened 5 months ago

Tempystral commented 5 months ago

I am using Meta Bind to create a new note based on a template, and Modal Forms to populate the metadata in the new note. Populating the metadata works just fine, but when I submit my form, the modal does not close.

To Reproduce Here is the button I created with Meta Bind:

label: Add Game
hidden: false
class: ""
tooltip: ""
id: ""
style: primary
actions:
  - type: templaterCreateNote
    templateFile: Templates/Kusogrande_template_test.md
    folderPath: Hobby/Kusogrande/Games
    fileName: NewKusograndeGame
    openNote: true

Here is my templater code:

const modalForm = app.plugins.plugins.modalforms.api;
const result = await modalForm.openForm('AddKusograndeGame');

tR += `---
platform: ${result.get("platforms")}
rom-link: ${result.get("rom")}
manual: ${result.get("manual")}
guide: ${result.get("guide")}
rating: 
new game: ${result.get("newgame")}
given out: false
templateVersion: kuso v2
---\n`;

if (tp.file.title.startsWith("NewKusograndeGame")) {
  await tp.file.rename(result.get("name"));
}

Expected behavior Submitting the form should close it.

Additional context I don't think Meta Bind is causing this issue because it also happened when I used the old buttons plugin that Meta Bind replaced.