A "persist" bug of .xhtml dialog in Zotero 7

176 views
Skip to first unread message

iseexuhs

unread,
Jul 19, 2023, 8:54:40 PM7/19/23
to zotero-dev
In Zotero 7 .xhtml dialog (such as selectitems.xhtml),it seems that the "persist" parameter does not work. I mean the window size can't not be persisted in next dialog opening if user changed the windows size.

You can check it by using:

    var io = { dataIn: [1, 2], dataOut: null };
    window.openDialog("chrome://zotero/content/ingester/selectitems.xhtml",
      "a", "chrome,modal,centerscreen,resizable=yes", io);

XY Wong

unread,
Jul 20, 2023, 11:00:38 AM7/20/23
to zotero-dev
thanks for reporting. I've created a pr[1] for this bug and should be fixed after merging.

iseexuhs

unread,
Jul 30, 2023, 2:00:18 AM7/30/23
to zotero-dev
In beta 26, this is still not fixed.

XY Wong

unread,
Jul 30, 2023, 10:40:22 PM7/30/23
to zotero-dev
It works for me on MacOS, Zotero 7.0.0-beta.26+6dcc70f53

iseexuhs

unread,
Jul 31, 2023, 11:50:57 AM7/31/23
to zotero-dev
Thanks for reply.

I checked this in Mac Zotero 7.0.0-beta.26+6dcc70f53.
It's found that the "persist" feature only works for the zotero built-in selectitems.xhtml dialog. 
It is valid in the window Dialog that user creates, although the core codes are the same as those of selectitems.xhtml. And this issue does not exist in Zotero 6.
Please help check it. Thanks a lot.

XY Wong

unread,
Jul 31, 2023, 11:57:40 AM7/31/23
to zotero-dev
If you have problem with your own code, please show the source; otherwise we are not able to help.

iseexuhs

unread,
Aug 5, 2023, 1:20:41 AM8/5/23
to zotero-dev
I figured it out. Only when the .xhtml window id is id="zotero-select-item-dialog", the persist feature can work. This is different in Zotero 6.

Thanks a lot.

Dan Stillman

unread,
Aug 5, 2023, 3:28:09 AM8/5/23
to zoter...@googlegroups.com
On 8/5/23 1:20 AM, iseexuhs wrote:
I figured it out. Only when the .xhtml window id is id="zotero-select-item-dialog", the persist feature can work. This is different in Zotero 6.

Wait, what? Can you explain exactly what you're doing?

You shouldn't be reusing the ids of built-in windows, if that's what you're suggesting.

iseexuhs

unread,
Aug 5, 2023, 3:43:38 AM8/5/23
to zotero-dev
Yep, I compared my codes with the built-in selectitems.xhtml line by line for several times, I am very sure that only when the .xhtml window id is set to id="zotero-select-item-dialog", the persist feature can work.

It is very different from Zotero 6. If the Zotero team is doubting about this, you can check it. Thanks a lot.
Message has been deleted
Message has been deleted

Dan Stillman

unread,
Aug 5, 2023, 3:53:42 AM8/5/23
to zoter...@googlegroups.com
On 8/5/23 3:43 AM, iseexuhs wrote:
Yep, I compared my codes with the built-in selectitems.xhtml line by line for several times, I am very sure that only when the .xhtml window id is set to id="zotero-select-item-dialog", the persist feature can work.

Again, can you please just explain exactly what you're trying to accomplish in your plugin and provide example code that's not doing what you expect? You should not be using "zotero-select-item-dialog" for an id in your plugin.

iseexuhs

unread,
Aug 5, 2023, 3:57:24 AM8/5/23
to zotero-dev
My .xhtml codes are shown below, and I did not include width/height parameters in window.openDialog()

As marked below, only when the .xhtml window id is set to id="zotero-select-item-dialog", the persist feature can work.
------

<?xml version="1.0"?>

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://zotero/skin/zotero.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://zotero/locale/zotero.dtd">
<window xmlns:html="http://www.w3.org/1999/xhtml"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="zotero-select-item-dialog"
title="&zotero.selectitems.title;" width="400" height="600"
persist="width height screenX screenY"
onload="myPlugin_Ingester_Interface_SelectEmoji.init()">
<dialog
buttons="cancel,accept"
id="zotero-selectEmoji">

<script>
var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
Services.scriptloader.loadSubScript("chrome://zotero/content/include.js", this);
Services.scriptloader.loadSubScript("chrome:/myPlugin/content/selectionDialog/selectEmoji.js", this);
Services.scriptloader.loadSubScript("chrome://zotero/content/customElements.js", this);
</script>

<vbox id="zotero-select-Emoji-container" flex="1">
<hbox align="center">
<label><html:h3 id="zotero-selectEmoji-intro">选择表情</html:h3></label>
        </hbox>
<box flex="1">
<richlistbox id="zotero-selectEmoji-links" flex="1"></richlistbox>
</box>
</vbox>
</dialog>
</window>

XY Wong

unread,
Aug 7, 2023, 9:24:43 AM8/7/23
to zotero-dev
Seem like you may have misunderstanding to the 'persist'.

1. the persisted window must have `id` and `persist` attributes.

2. the windows with the same `id` share the initial attributes in `persist`.

It doesn't make sense for your custom select dialog to have the same initial width and height as Zotero's built-in one. Don't assign them the same window id.
Message has been deleted

Dan Stillman

unread,
Aug 8, 2023, 4:51:43 AM8/8/23
to zoter...@googlegroups.com
On 8/7/23 12:45 PM, iseexuhs wrote:
If users change the window size, it should be persisted in next opening. That is the "persist" feature of window size.

and the real truth is: if I remove the .xhtml window id="zotero-select-item-dialog" from above codes, the persist feature will fail.

Do you understand that the id is an attribute that you need to set yourself, to a unique id for your window? You keep talking about removing `id="zotero-select-item-dialog"`, but no one is saying to do that — we're saying you shouldn't be using the id of a Zotero window, because you'll mess up window positioning of the Select Items dialog for Zotero users. You need to set that to your own id. This absolutely works.

If you're having trouble, you need to show us the full code — the exact JS code and the exact .xhtml file — that you're using that's not working for you. All you've shown us so far is an .xhtml file with `id="zotero-select-item-dialog"` in it, which obviously works, because `persist` works when there's an `id` on the window. But you can't use the id of a Zotero window.

iseexuhs

unread,
Aug 8, 2023, 4:55:45 AM8/8/23
to zotero-dev
yep, it is already ok now. The window id must be set, if not set, it won't have persist feature.

Thanks a lot.

Reply all
Reply to author
Forward
0 new messages