PDA

View Full Version : [OPEN] [FIXED]Adding TabItem to empty TabPanel



Colin Alworth
11 Jun 2009, 6:09 AM
I apologize if this is not a bug, but merely my misuse of the TabPanel and TabItem, but this seems as though it should work...

Build a TabPanel and add a TabItem. Then, after the TabItem is renderered, add another tab. This works as expected.

Viewport vp = new Viewport();
RootPanel.get().add(vp);

TabItem t1 = new TabItem();
t1.add(new Label("This is Tab 1"));

final TabItem t2 = new TabItem();
t2.add(new Label("This it Tab 2"));

final TabPanel panel = new TabPanel();
panel.add(t1);
vp.add(panel);
vp.add(new Button("add it", new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
panel.add(t2);
}
}));
vp.layout();After the button is pushed, there are two tabs, and both have visible content.

To see the bug then, try not adding the first tab - after the add button is pushed, the content of the only tab added cannot be seen.

Viewport vp = new Viewport();
RootPanel.get().add(vp);

//TabItem t1 = new TabItem();
//t1.add(new Label("This is Tab 1"));

final TabItem t2 = new TabItem();
t2.add(new Label("This it Tab 2"));

final TabPanel panel = new TabPanel();
//panel.add(t1);
vp.add(panel);
vp.add(new Button("add it", new SelectionListener<ButtonEvent>() {
@Override
public void componentSelected(ButtonEvent ce) {
panel.add(t2);
}
}));
vp.layout();While I have not set the height for this TabPanel explicitly, this should not be necessary, and in fact it does not help - the content of the tab remains empty even with panel.setHeight(100);.

I don't think I am doing this wrong - the same issue can be demonstrated by modifying the advanced tabs example (http://extjs.com/examples-dev/explorer.html#advancedtabs) to not add any tabs to start with by remving the while loop. Note that adding second tab added appears to restore the first one.

sven
11 Jun 2009, 12:35 PM
Fixed in SVN

Luming Lai
16 Jun 2009, 6:14 AM
Can you please post a workaround for this? We can't migrate to 2.0 right now (especially not HEAD), but we need a solution to this ASAP.

I would be happy to deal with the underlying elements or anything, really.

Thanks

sven
16 Jun 2009, 6:15 AM
onInsert in containers insert method must be called after adding it to the internal list.