Opened 11 years ago

Closed 11 years ago

#5546 closed defect (duplicate)

StackContainer not created as Tab contents if tab not visible

Reported by: stenduncan@… Owned by:
Priority: high Milestone:
Component: Dijit Version: 1.0
Keywords: StackContainer, TabContainer Cc:
Blocked By: Blocking:

Description

I am porting from 0.4.3 to 1.0.2. In my original code, I had a TabContainer? with 3 tabs. One tab (not the default selected) contained a PageContainer?. This all worked fine in 0.4.3. Now, when I have converted to using StackContainer?, I am getting errors when dojo parses the StackContainer? on load.

I will attach a small example.

To reproduce (in Firefox 2.x)

  1. Fix paths in the files to point to whatever Dojo installation you're using
  1. load file "cont.html" in the browser
  1. Notice that an error "s has no properties" is generated somewhere inside marginBox() called from startup().

To see the StackContainer? working correctly:

  • run file "cont2.html" in the browser

--OR--

  • change the default selected tab in "cont.html" to be tab03 (the tab containing the StackContainer?)

This is rather problematic for me. I'm hoping I can work around this problem by creating the StackContainer? programmatically (haven't tried that yet), but it's really not ideal.

I have tried setting the size in "style" or "class" but since the element is not being drawn, those values are not picked up at the time of creation.

Is there any other workaround that I'm missing?

Attachments (1)

cont.zip (2.0 KB) - added by guest 11 years ago.
Test case

Download all attachments as: .zip

Change History (9)

Changed 11 years ago by guest

Attachment: cont.zip added

Test case

comment:1 Changed 11 years ago by bill

Cc: stenduncan@… removed
Reporter: changed from guest to stenduncan@…
severity: majornormal

Why are you using iframes? You can supply an href argument to a ContentPane? and I suspect that will work better for you, and avoid loading dojo multiple times. If you do that does it work for you?

comment:2 in reply to:  1 Changed 11 years ago by guest

Does that matter? As far as I could tell, the problem is not related to the use of iframes, but to the fact that the StackContainer? was not visible at the time of creation. The fact that I can simply set the tab with the StackContainer? as the active tab and then everything works seems to point in that direction as well. Correct me if I'm wrong on this point.

As to why I'm using iframes, the reasons are many and varied. I have provided an extremely cut-down snippet from a much larger and more complex app to demonstrate the problem.

-- stenduncan

comment:3 Changed 11 years ago by bill

Ah, yes, if the StackContainer? isn't visible at the time of creation things won't work. This is a known limitation of all the layout widgets, since they do JS sizing and that doesn't work on hidden nodes. The exception to this case is when StackContainer? is a direct child of the TabContainer?, or if the hierarchy is TabContainer? --> ContentPane? --> StackContainer? where the ContentPane? has just a single child.

comment:4 in reply to:  3 ; Changed 11 years ago by guest

This limitation of requiring widgets to be visible in order to be created seems rather severe to me. It seems to negate the useability and usefulness of the StackContainer/TabContainer? widgets.

Do you know if this problem can be worked around by programmatically creating the StackContainer?? Do I just not call the startup method until I know the widget is visible?

What about adding children dynamically to the StackContainer?? Do I need special handling there if I create child "panes" that are not visible on creation?

-- stenduncan

comment:5 in reply to:  4 Changed 11 years ago by guest

I am facing a similar problem, my layout is like StackContainer? - > Content Pane intially. Later I add a Tab Container to Content pane programmatically. I dont see it visible.

comment:6 in reply to:  4 Changed 11 years ago by guest

More problems ...

I am now programmatically creating the StackContainer?. I don't call startup() until my tab pane gets selected.

First problem: when I add a child to the created, but not yet visible (not started) StackContainer?, I am getting the same error (from marginBox) for the child as I was originally getting for the container. -- I worked around this by setting the "layout" attribute of the StackContainer? to false.

Next problem: when I select the tab that has my StackContainer? (and child), I then call startup() and I'm now getting the error at this point - "s has no properties". Stack trace: _getMarginExtents(div#contWid, null) _getMarginBox(div#contWid, null) marginBox(div#contWid, undefined) resize(undefined) startup()

The tab does appear and my contents are partially shown. In a different code path, I (programmatically) select the tab first and then create the new child. That seems to work.

Keep in mind that both of these variations worked in the good old PageContainer? (oh, how I miss it!) I could have a hidden PageContainer? and add one or more children and then display it and it all worked fine.

What the <expletive deleted> do I do now? Suggestions? Anyone?

comment:7 Changed 11 years ago by bill

Well, again, this all works perfectly as long as you make a hierarchy of layout widgets and contentpanes, without anything in the middle like an iframe or a stray div. You shouldn't need to muck with when startup() is called, etc.

First problem: when I add a child to the created, but not yet visible (not started) StackContainer, I am getting the same error (from marginBox) for the child as I was originally getting for the container. -- I worked around this by setting the "layout" attribute of the StackContainer to false.

Sounds like a bug and I don't know why it's happening. StackContainer.addChild has an if(this._started){ block that should prevent the marginBox call.

Next problem: when I select the tab that has my StackContainer (and child), I then call startup() and I'm now getting the error at this point - "s has no properties". Stack trace: _getMarginExtents(div#contWid, null) _getMarginBox(div#contWid, null) marginBox(div#contWid, undefined) resize(undefined) startup()

OK, maybe another bug. If you can provide test cases we can take a look.

comment:8 Changed 11 years ago by bill

Resolution: duplicate
Status: newclosed

I filed #5672 to summarize the issue in this bug.

Note: See TracTickets for help on using tickets.