Div does not fit embedded UI

I followed the tutorial in the Book of Vaadin for embedding UIs in Web Pages. Everything works fine when the UI does not implement ViewChangeListener and has a navigator. When it dows, the div element to embed the UI does not expand to fit UI content in Chrome and Firefox. In IE, it works. When not embedded in a Web page, everything is fine in all browsers.

Here is my UI code:

public class MyUI extends UI implements ViewChangeListener {

    Navigator navigator;

    @Override
    protected void init(VaadinRequest request) {
        getSession().setLocale(new Locale("pt", "BR"));
        VerticalLayout layout = new VerticalLayout();
        layout.setSizeFull();
        this.setContent(layout);
        
        Panel view = new Panel();
        view.setSizeUndefined();
        view.setStyleName("main-view");
        
        layout.addComponent(view);
        layout.setComponentAlignment(view, Alignment.TOP_CENTER);
        
        navigator = new Navigator(this, view);
        
        navigator.addViewChangeListener(this);
        
        navigator.addView("", new MainView());
        
    }
    
    @Override
    public boolean beforeViewChange(ViewChangeEvent event) {
        return true;
    }

    @Override
    public void afterViewChange(ViewChangeEvent event) {
        
    }

}

Is there anything wrong?