Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#17072 closed defect (invalid)

Dialog startup called too early

Reported by: Mark DeMichele Owned by: bill
Priority: undecided Milestone: tbd
Component: Dijit Version: 1.8.3
Keywords: Cc:
Blocked By: Blocking:


I want into an issue with Dialog. I set the contents to some html with a dijit. One of my dijits is handling it's startup by measure it's dom contents. However, since the dialog calls startup while display:none is set, all the dom nodes under it return 0 for with and height. This goes against the idea of "startup" being a place to peform layout.

I demonstrated the problem here

I fixed it by delaying to the call to startup until after the display:none is reset to display:"". For now, I did this in a descendent class that I'll use instead of Dialog, but it would nice if Dialog was updated to just move the call to this.startup.

Here's my code.

    function (declare, Dialog) {

        return declare("xl.util.Dialog", [Dialog], {

            * Need to delay startup. So dijits inside them are sized properly
            startup: function () {
                if (this._disableStartup)

            show: function () {
                this._disableStartup = true;
                try {
                } finally {
                    this._disableStartup = false;

            _onShow: function () {
                this._disableStartup = false;


Change History (4)

comment:1 Changed 6 years ago by bill

Resolution: invalid
Status: newclosed

Actually, you need to put your sizing code in the resize() method. This is the contract for widgets that do sizing.

comment:2 Changed 6 years ago by Mark DeMichele

I would like to respectively dispute this. :)

I'm not actually doing resizing. My dijit creates a bunch a domNodes and I need to position them within the dijit. My calculations are based on the sizes of the individual domNodes.

It says this in _WidgetBase in reference to when the startup() is called.

"This is useful for composite widgets that need to control or layout sub-widgets."

Also, I could be wrong, but by looking at _LayoutWidget.js, the resize() guy is called as a result of startup(). So, this wouldn't really fix anything since startup() is being called when display = none and when this is the case the browsers return 0 for width and height for everything inside that container.

Please reconsider the closing of this. If you would like to discuss this in more detail, I can make myself available. Thanks.

comment:3 Changed 6 years ago by bill

Hmm, I think your custom widgets (inside the Dialog) need to extend _LayoutWidget or do something similar. In other words, put your measurement code in resize(), and then make startup() call resize() if the parent is *not* a layout container. I agree it doesn't match the comment in _WidgetBase, so I'll update that. And also I agree that the name resize() is a misnomer.

If you know that your widget will always appear inside of an extension of _ContentPaneResizeMixin such as Dialog, you can just move your sizing code to resize().

comment:4 Changed 6 years ago by bill

In [31339]:

update doc about startup() and resize(), no code changes, refs #17072 !strict

Note: See TracTickets for help on using tickets.