Site logo

Bookmarks panel bug

Presumably beginning from the version CS4 (and still present in CC 2018), a scripting bug has been introduced which lies in unreliable naming (renaming) bookmarks by script with the Bookmarks panel open. To work around the problem, if the panel is open, the script — in CS4 and above — should temporarily close it at start and then reopen it at the end. I did it (in my Make font catalog script) like so:

if (appVersion >= 6) {
	var bookmarksPanelWasHidden = false,
	bookmarksPanel = app.panels.item("$ID/Bookmarks");

	if (bookmarksPanel.isValid && bookmarksPanel.visible) {
		bookmarksPanel.visible = false;
		bookmarksPanelWasHidden = true;
	}
}

If InDesign’s version is CS4 or above, remember whether the Bookmarks panel has been closed by the script at start in the bookmarksPanelWasHidden variable.
At the end, restore the panel if bookmarksPanelWasHidden is true.

if (appVersion >= 6) {
	if (bookmarksPanelWasHidden) {
		bookmarksPanel.visible = true;
	}
}

Note: I reference the Bookmarks panel in locale independent form so it should work (theoretically) in all language versions of InDesign.