Implement "visible" parameter in menus.create and menus.update

VERIFIED FIXED in Firefox 63

Status

P3
enhancement
VERIFIED FIXED
6 months ago
4 months ago

People

(Reporter: robwu, Assigned: robwu)

Tracking

(Blocks: 1 bug, {dev-doc-complete})

unspecified
mozilla63
dev-doc-complete

Firefox Tracking Flags

(firefox63 verified)

Details

Attachments

(2 attachments)

(Assignee)

Description

6 months ago
Currently, when an extension wants to hide a menu, they have to resort to one of the following methods hacks:
- Remove menu via the remove or removeAll methods in the menus or contextMenus namespace.
  (disadvantage: menu order is lost because menus are currently shown in the order of creation)
- Update the menu with the update method, and set one of the values to something that never matches.

Neither method is ideal, and I was wondering whether there is a better way to offer this functionality.
Turns out, Chrome's contextMenus API already offers the "visible" property which fulfills these needs.

Chrome supports this since version 62:
https://bugs.chromium.org/p/chromium/issues/detail?id=463476
https://developer.chrome.com/extensions/contextMenus#property-createProperties-visible

Comment 1

6 months ago
Can we also implement enabled [1]?

[1] https://developer.chrome.com/extensions/contextMenus#property-createProperties-enabled
Flags: needinfo?(rob)
(Assignee)

Comment 2

6 months ago
(In reply to kernp25 from comment #1)
> Can we also implement enabled [1]?
> 
> [1] https://developer.chrome.com/extensions/contextMenus#property-createProperties-enabled

The "enabled" property is already supported by Firefox.
Flags: needinfo?(rob)
This seems like a good idea for both usability and compatibility.
Severity: normal → enhancement
Priority: -- → P3
(Assignee)

Comment 4

6 months ago
Created attachment 9002469 [details]
Bug 1482529 - Support "visible" in menus.create and menus.update
Comment on attachment 9002469 [details]
Bug 1482529 - Support "visible" in menus.create and menus.update

Shane Caraveo (:mixedpuppy) has approved the revision.
Attachment #9002469 - Flags: review+

Comment 6

6 months ago
Pushed by rob@robwu.nl:
https://hg.mozilla.org/integration/autoland/rev/f66ffcb2e82a
Support "visible" in menus.create and menus.update r=mixedpuppy

Comment 7

6 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/f66ffcb2e82a
Status: ASSIGNED → RESOLVED
Last Resolved: 6 months ago
status-firefox63: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla63
(Assignee)

Comment 8

6 months ago
Note for compat table ( https://github.com/mdn/browser-compat-data ).
This feature is supported since Firefox 63, Chrome 62 (desktop only) and Opera 49.
Keywords: dev-doc-needed

Comment 9

6 months ago
Created attachment 9004550 [details]
Bug1482529.gif

This issue is verified as fixed on Firefox 63.0a1(20180827100129) under Win 7 64-bit and Mac OS X 10.13.3.

The “visible” parameter work as expected for menus.create and menus.update.

Please see the attached video.

Updated

6 months ago
Status: RESOLVED → VERIFIED
status-firefox63: fixed → verified
I've added `visible` to the `createProperties` object in https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/menus/create, and also added it to the compat data.

Marking as dev-doc-complete, but please let me know if we need anything else.
Keywords: dev-doc-needed → dev-doc-complete
You need to log in before you can comment on or make changes to this bug.