Closed
Bug 978249
Opened 11 years ago
Closed 11 years ago
"viewNode is null" when clicking on widget located in panel
Categories
(Firefox :: Extension Compatibility, defect)
Firefox
Extension Compatibility
Tracking
()
RESOLVED
INVALID
People
(Reporter: jorgev, Unassigned)
References
Details
Attachments
(1 file)
(deleted),
application/x-xpinstall
|
Details |
I'm writing some demos for CustomizableUI and ran into this problem.
STR:
1) Install add-on in the attachment.
2) Click on the smiley face. You should see a panel with a select box and button (if you want to see them enabled, have https://archive.org/details/mp3_1_1535-58 opened in the active tab).
3) Customize Firefox and move the smiley to the menu panel.
4) Click on the smiley face in the menu panel. Same result (it looks ugly, but that's a separate problem).
5) Restart Firefox.
6) Click on the smiley face in the menu panel. You'll see no panel and the following error:
viewNode is null panelUI.xml:186
That's one of the first lines in this method:
<method name="showSubView">
If you modify the add-on to inject the widget directly into the panel, the error happens right away. So, it looks like there's something that fails to initialize only when the widget is in the panel right from the start, but it does initialize if the widget is in the main toolbar before.
Updated•11 years ago
|
Flags: needinfo?(gijskruitbosch+bugs)
Comment 1•11 years ago
|
||
This is because you're appending the panelview to the mainPopupSet. It's meant to be appended to the panelUI's subview collection inside the main menu panel. Admittedly our docs on this are rubbish, but that's why this isn't working. The reason it works when it's initially in the navbar and you open the panel first is that we stick it "back" in there ourselves after we close the panel with your panelview, and we happened to use a different way of finding the panelview in the code that pulls it out, mostly because it was simplest to just use getElementById there...
I /think/ (but can't easily test right now) that changing:
doc.getElementById("mainPopupSet").appendChild(panel);
to:
doc.getElementById("PanelUI-multiView").appendChild(panel);
should make things work.
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: needinfo?(gijskruitbosch+bugs)
Resolution: --- → INVALID
Comment 2•11 years ago
|
||
(It seems we do show an error for the navbar case, too, actually:
console.error:
[CustomizableUI]
Could not find the view node with id: aus-view-panel, for widget: aus-view-button.
)
Reporter | ||
Comment 3•11 years ago
|
||
(In reply to :Gijs Kruitbosch from comment #2)
> (It seems we do show an error for the navbar case, too, actually:
>
> console.error:
> [CustomizableUI]
> Could not find the view node with id: aus-view-panel, for widget:
> aus-view-button.
>
> )
Since I'm testing with a restartless add-on, I'm using a window listener to inject the content using onOpenWindow. I see this error at startup and for every new window that is opened, which suggests the widget is built before these listeners are fired and I can add the content to the DOM of the window. Is there a different way I should be adding the panelview to the DOM?
Flags: needinfo?(gijskruitbosch+bugs)
Comment 4•11 years ago
|
||
(In reply to Jorge Villalobos [:jorgev] from comment #3)
> (In reply to :Gijs Kruitbosch from comment #2)
> > (It seems we do show an error for the navbar case, too, actually:
> >
> > console.error:
> > [CustomizableUI]
> > Could not find the view node with id: aus-view-panel, for widget:
> > aus-view-button.
> >
> > )
>
> Since I'm testing with a restartless add-on, I'm using a window listener to
> inject the content using onOpenWindow. I see this error at startup and for
> every new window that is opened, which suggests the widget is built before
> these listeners are fired and I can add the content to the DOM of the
> window. Is there a different way I should be adding the panelview to the DOM?
There's three, maybe two options. One is you could use a custom widget type (ie type: custom, and generate the button + panelview in onBuild) or you could try using DOMContentLoaded instead of load... I'm not sure if that would work or not, however, because XUL document loads and overlays and all of that are really weird.
IIRC, overlays work in bootstrapped chrome manifests, which would also work. Did I misremember/misunderstand that?
Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(jorge)
Reporter | ||
Comment 5•11 years ago
|
||
(In reply to :Gijs Kruitbosch from comment #4)
> There's three, maybe two options. One is you could use a custom widget type
> (ie type: custom, and generate the button + panelview in onBuild) or you
> could try using DOMContentLoaded instead of load... I'm not sure if that
> would work or not, however, because XUL document loads and overlays and all
> of that are really weird.
I'll give that a look, thanks.
> IIRC, overlays work in bootstrapped chrome manifests, which would also work.
> Did I misremember/misunderstand that?
No, overlays are not supported: https://developer.mozilla.org/en-US/docs/Chrome_Registration#Instructions_supported_in_bootstrapped_add_ons.
Flags: needinfo?(jorge)
Reporter | ||
Comment 6•11 years ago
|
||
FTR, using DOMContentLoaded fixed this problem.
Comment 7•11 years ago
|
||
(In reply to Jorge Villalobos [:jorgev] from comment #6)
> FTR, using DOMContentLoaded fixed this problem.
Sweet, thanks for letting us know. :-)
Comment 8•10 years ago
|
||
(In reply to :Gijs Kruitbosch from comment #1)
> This is because you're appending the panelview to the mainPopupSet. It's
> meant to be appended to the panelUI's subview collection inside the main
> menu panel. Admittedly our docs on this are rubbish, but that's why this
> isn't working. The reason it works when it's initially in the navbar and you
> open the panel first is that we stick it "back" in there ourselves after we
> close the panel with your panelview, and we happened to use a different way
> of finding the panelview in the code that pulls it out, mostly because it
> was simplest to just use getElementById there...
>
> I /think/ (but can't easily test right now) that changing:
>
> doc.getElementById("mainPopupSet").appendChild(panel);
>
> to:
>
> doc.getElementById("PanelUI-multiView").appendChild(panel);
>
> should make things work.
In the docs at https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/CustomizableUI.jsm/API-provided_widgets can you add a note for this please? Something like "The 'view' widgets should be added inside '#PanelUI-multiView'. Right after where it says the following would be good.
> This is useful especially for 'view' type widgets that need to construct their views on the fly (e.g. from bootstrapped add-ons).
You need to log in
before you can comment on or make changes to this bug.
Description
•