Zotero ItemTreeManager API causing CSS column resizing bug

8 views
Skip to first unread message

Dom

unread,
Jan 5, 2026, 6:50:45 PM (2 days ago) Jan 5
to zotero-dev
To add a custom column, the `Zotero.ItemTreeManager.registerColumn` function takes a dataKey for the custom column, as well as the plugin ID.

The plugin id and dataKey are joined with a dash to create the full key for the custom column (https://github.com/zotero/zotero/blob/main/chrome/content/zotero/xpcom/pluginAPI/pluginAPIBase.mjs#L317)

But for applying CSS styles, the custom column's class is set to `{datakey}-item-tree-main-default` and its datakey retrieved from the class by splitting the class name until the first "-" (https://github.com/zotero/zotero/blob/main/chrome/content/zotero/components/virtualized-table.jsx#L1524).

But because the pluginAPI has formatted the custom column datakey as "{pluginID}-{mainKey}", the code trying to recover the column data key from the CSS class will split until the dash and only retrieve the plugin ID.

This means that the check to see whether that custom column has already had a style applied (https://github.com/zotero/zotero/blob/main/chrome/content/zotero/components/virtualized-table.jsx#L1529) will fail and therefore a new rule will be inserted (https://github.com/zotero/zotero/blob/main/chrome/content/zotero/components/virtualized-table.jsx#L1531) whenever the style map is refreshed.

In Zotero plugins I author, this resulted in this issue (https://github.com/Dominic-DallOsto/zotero-reading-list/issues/27 or see an example video here https://github.com/Dominic-DallOsto/zotero-annotations-count/issues/7) where anything that caused the column style sheets to be refreshed (like removing and re-adding a column) would add duplicate CSS rules to the same column, which would conflict and make resizing the column exhibit strange behaviours where changing the size of one column would change the size of multiple other columns.

I imagine a solution could involve:

* joining the plugin ID and column data key with a different character than a dash
* replacing any dashes in the plugin ID before using it in the custom column data key
* updating the code that automatically removes any custom columns registered by a plugin when that plugin is deactivated

A workaround is to register the custom column with the plugin ID and data key already combined (without the dash) as the column data key and the plugin ID as an empty string. This breaks the automatic column removal on plugin deactivation though

Xiangyu Wang

unread,
Jan 6, 2026, 4:12:08 AM (yesterday) Jan 6
to zoter...@googlegroups.com
Thanks for the report. We will fix this issue.



--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zotero-dev+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/zotero-dev/fbd320a3-7b43-4c31-8fba-39c3757a13a3n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages