Closed Bug 890265 Opened 8 years ago Closed 8 years ago

`onBuild` for widget type "custom" seems not called if the widget is in the PANEL area

Categories

(Firefox :: Toolbars and Customization, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: zer0, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [Australis:M?])

In the new Button in jetpack, we use currently the type custom. It seems that `onBuild` is called only if the button is in the navbar. Step to reproduce it:

1. Create a custom widget via CustomizableUI in NAVBAR
2. Customize the UI, and move the widget in the PANEL
3. Close Firefox
4. Reopen Firefox
5. The Widget is in the panel, but `onBuild` is not called – so all the customization are not applied.

This is a blocker for us to land our new UI components; not sure if I'm doing something strange but basically here the `createWidget` code I'm using:

  CustomizableUI.createWidget({
    id: toWidgetID(id),
    type: 'custom',
    removable: true,
    defaultArea: AREA_NAVBAR,
    allowedAreas: [ AREA_PANEL, AREA_NAVBAR ],

    onBuild: function(document) {
      let window = document.defaultView;

      let node = document.createElementNS(XUL_NS, 'toolbarbutton');

      if (ignoreWindow(window))
        node.style.display = 'none';

      node.setAttribute('id', this.id);
      node.setAttribute('class', 'toolbarbutton-1 chromeclass-toolbar-additional');
      node.setAttribute('width', SIZE[size] || 16);
      node.setAttribute('type', type);

      views[id] = {
        events: bus,
        area: this.currentArea
      };

      node.addEventListener('command', function(event) {
        if (views[id])
          emit(views[id].events, 'click', event);
      });

      return node;
    }
  });

Notice that if I change the position of the widget in the NAVBAR, the `onBuild` is called, and the position is updated in the profile.
Whiteboard: [Australis:M?]
onBuild will only be called when the user opens the panel the first time. I don't think this is a bug. Why do you need it to be called before the panel is opened?
See the 3rd point: The browser is closed, so when the panel is opened after the user moved the button in the previous session, it's actually the first time that he open the panel in this new session. So I expected that the `onBuild` is called.
Tested on latest UX build against the same code base, now seems working. Not sure if it was some mistake I did previously or some changes in the UX build.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.