Closed Bug 1000424 Opened 10 years ago Closed 10 years ago

BUttons in new menu panel cannot be retrieved on window load

Categories

(Firefox :: Toolbars and Customization, defect)

30 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: realRaven, Unassigned)

References

(Blocks 1 open bug)

Details

I do some customization with my new uiPanel button for my Addon QuickPasswords. Problem is when the button is configured to be within the new uiPanel, getElementById cannot find it. it works for everything else and also for the button if it is in the main toolbar.
I have tried to move the code that looks for this button to an observer on browser-delayed-startup-finished but it is still the same: all other buttons, menu items etc are found via getElementById but the button cannot be found. I seem to have to use it at least once so that it can be discovered?
Looks like this is "by design". I have coded the workaround using a toolbar observer on the CustomizableUI interface through the onWidgetAfterDOMChange event:

  const { CustomizableUI } = Components.utils.import("resource:///modules/CustomizableUI.jsm", {});
  if (CustomizableUI)
    CustomizableUI.addListener(QuickPasswords.ToolbarListener);


QuickPasswords.ToolbarListener = {
  onWidgetAfterDOMChange: function (node, nextNode, container)  {
    if (node && node.id === 'QuickPasswords-toolbar-button') {
      node.classList.toggle('australis', QuickPasswords.Preferences.getBoolPref('skin.australis'));
      QuickPasswords.initToolbarLock(null, node);
    }
  }
}
Use getWidget() instead of the observer stuff.


It's a duplicate of bug 941903.
This is documented on the Australis add-on compatibility page[1] of MDN, linked from the Firefox 29 for developers page.

    Many add-ons check whether their button is in the toolbox (rather than in a toolbar or some other  
    visible place) by checking the result of document.getElementById(). This is no longer enough. If your 
    button is in the menu panel, it will not be moved there until the menu panel is first shown. Instead, 
    use:
    CustomizableUI.getPlacementOfWidget("mytoolbarbuttonId")
    This will return null if and only if the widget is in the palette.

Please use getWidget or getPlacementOfWidget instead.

[1] https://developer.mozilla.org/en-US/Firefox/Australis_add-on_compat#Known_issues_related_to_add-ons
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.