New Tab Scripting Behaviors

Running into a couple unexpected outcomes using the new “tab” scripting options; not sure if I’ve found a bug or I’m using it wrong.

On an M1 Pro Mac running Ventura 13.3.1 (a), Drafts 39.0 (259), the command alert(app.currentWindow.canOpenTab) returns false, even though I think this should always be true?

Additionally, the command:

const g = app.currentWindow.openInNewTab(Draft.find("DRAFT_UUID"))


where the UUID is a legitimate draft UUID, opens the requested draft, but the alert returned is also false. On the chance that triggering the alert causes the false for some reason, I also tried this with displayInfoMessage and still got a falsy result.

Essentially, openInNewTab does work, but I can’t seem to get a true response from either openInNewTab or canOpenTab. I do love the tab capability, though — thanks for adding it!

An update that with Drafts 39.1 (263), app.currentWindow.openInNewTab(Draft.find("DRAFT_UUID")) now returns true as expected (whereas in Drafts 39.0 it had been returning false).

But, at least on my Mac, alert(app.currentWindow.canOpenTab) now returns undefined, when it should always return true (in Drafts 39.0, it was returning false). Also, whereas something like:

alert(JSON.stringify(app.currentWindow, ["isDraftListVisible"], 2))

returns an object — { "isDraftListVisible": true } — the same command with “canOpenTab” just returns {}, suggesting “canOpenTab” isn’t defined.

Hope this is helpful. Thank you!

1 Like

That is a screw up in the documentation, apologies. It should be canCreateTab, not canOpenTab. Off to fix the docs.