Closed Bug 1266455 Opened 8 years ago Closed 7 years ago

contexts in contextMenus for parent & child menus

Categories

(WebExtensions :: Frontend, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1324429

People

(Reporter: eros_uk, Unassigned)

Details

(Whiteboard: triaged[intent-to-close])

FF45.0.2 Win7

In nested contextMenu i.e. where there is a parent and child (submenu), setting the contexts on the parent menu should apply to its child-menus (unless specifically stated otherwise)

Via trial & error, the only way I could get the menus to show/hide based on contexts was to set the contexts for all of them.

- Setting the contexts on parent menu only has no effect.
- Setting the contexts on child-menus shows/hides the child-menu (although it shows an unsightly small square) but not the parent.

Here is an example:

var contexts = ['selection', 'link'];

browser.contextMenus.create({'title': 'Title', 'id': 'parent', 'contexts': contexts});
browser.contextMenus.create({'title': 'Action 1', 'parentId': 'parent', 'id': 'child1', 'contexts': contexts, 'onclick': process});
browser.contextMenus.create({'title': 'Action 2', 'parentId': 'parent', 'id': 'child2', 'contexts': contexts, 'onclick': process});
The limitation seems same to Google Chrome's spec.
http://stackoverflow.com/questions/11468798/create-two-child-menus-for-every-parent-menu-in-chrome-extension
http://stackoverflow.com/questions/14818714/adding-children-to-context-menu-links/18198476#18198476
I also think that child context menu items should inherit default `contexts` from the parent item, isntead of static defaults `["page"]`. But there is a problem: the change will break compatibility with Google Chrome.
Status: UNCONFIRMED → NEW
Ever confirmed: true
need to discuss on list if there is enough reason to break from following compatibility with Chrome in this area.
Priority: -- → P3
Whiteboard: triaged
Doing more with context menus was a frequent request in the developer survey.
Firefox 46: New Bug
The parent menu is not hidden by contexts anymore (same code as above).
Firefox 47:
Above bug is still present (parent menu does not hide according to context)
Is there a way we can do this that would avoid breaking compat. with Chrome? Otherwise I'd suggest won't fixing.
Whiteboard: triaged → triaged[intent-to-close]
Component: WebExtensions: Untriaged → WebExtensions: Frontend
The other bug has a patch.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.