pixiebrix / pixiebrix-extension

PixieBrix browser extension
https://www.pixiebrix.com
GNU Affero General Public License v3.0
83 stars 22 forks source link

Context menu items showing for mods that are not active #6443

Closed grahamlangford closed 1 month ago

grahamlangford commented 1 year ago

https://pixiebrix.slack.com/archives/C0436P48QHY/p1694551866880489

github-actions[bot] commented 7 months ago

This issue will be closed in 7 days unless the stale label is removed, or a comment is added to the issue.

fregante commented 7 months ago

From slack:

sticky context menus have been like playing whack a mole

We should move the registration out of the content script, context menus should not be registered on page load (which is when the content scripts run)

I think this bug happens because:

  1. the mod is updated/removed in the background
  2. when the content script runs, it just tries to register the context menu with the latest information, it has no recollection of the previous context menu that should now be removed

If context menus were handled entirely by the background page, then a mod update in the background would automatically be followed by "unregister all context menus, then register the ones that are enabled"

Then the page editor can register the dynamic context menus directly, perhaps via a special contextMenuId that starts with dynamic: so that they can be recognized and handled better.

fregante commented 7 months ago

Disregard. It looks like ensureContextMenu is already being called by the background page on load, which is good.

However the content script also calls it at every page load, which should probably be dropped and let the background page (and page editor) deal with registration independently:

Screenshot 3

There's no reason for every content script in every frame and every tab to request this on every load:

Screenshot 4
github-actions[bot] commented 4 months ago

This issue will be closed in 7 days unless the stale label is removed, or a comment is added to the issue.

github-actions[bot] commented 1 month ago

This issue will be closed in 7 days unless the stale label is removed, or a comment is added to the issue.

github-actions[bot] commented 1 month ago

This issue was closed because it has been stale for 7 days with no activity.