Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha Premium Member
    Join Date
    May 2010
    Posts
    11
    Vote Rating
    0
    mcarthum is on a distinguished road

      0  

    Default [2.2.6] LayoutContainer does not add children to DOM (sometimes)

    [2.2.6] LayoutContainer does not add children to DOM (sometimes)


    I've noticed that it's possible for components added to a LayoutContainer to become "attached" (onAttach() is invoked) but never actually added to the DOM (el().isConnected() returns false). Is this a bug or am I misunderstanding something? To me it seems that when onAttach()/onLoad() is invoked, a widget's element should actually be part of the DOM.

    Here is code to reproduce the problem (tested in FF and Chrome):

    Code:
    import java.util.logging.Logger;
    
    
    import com.extjs.gxt.ui.client.widget.LayoutContainer;
    import com.extjs.gxt.ui.client.widget.Text;
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.google.gwt.user.client.ui.Widget;
    
    
    public class Foo implements EntryPoint {
        
        private static final Logger logger = Logger.getLogger("Foo");
        
        @Override
        public void onModuleLoad() {
            LayoutContainer parent = new LayoutContainer();
            
            Widget child = new Text("Text") {
                
                @Override
                protected void onAttach() {
                    super.onAttach();
                    if (isAttached() && !el().isConnected()) {
                        logger.severe("Attached but not connected to DOM!");
                    }
                }
            };
            
            // Add child to parent
            parent.add(child);
            
            // Add and remove parent
            RootPanel.get().add(parent);
            RootPanel.get().remove(parent);
            
            // Remove and re-add child
            parent.removeAll();
            parent.add(child);
    
    
            // Add parent again -- child does not render
            RootPanel.get().add(parent);
        }
    }

  2. #2