Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Bug - Tab disappearing when EventHandler.getTarget() is invoked through native method

    Hi,
    i have encountered disappearing of Tabs from TabSet when there is a native click handler registered and EventHandler.getTarget() is invoked in this handler.

    I have managed to create simple test case which demonstrates this behavior.

    Test procedure:
    1. Click on the header of the first tab ('Tab 1')
    2. Click on the 'Test Bug' button
    3. Click on the header of the first tab ('Tab 1') again = this tab disappears

    There are other procedures that causes disappearing. Generally these always involve new tab created and header of a tab been selected for more than one time.

    Following error is thrown into the console
    Code:
    [ERROR] [tabstestcase] - 11:44:15.969:MDN3:WARN:Log:Specified ID: isc_Tab_0 collides with the ID for an existing SmartGWT component or object. The existing object will be destroyed and the ID bound to the new object.'
    When inspencting the Watch in the developer console, the isc_Tab_0 element is still a member of the TabSet but it is not visible and is located in the left top corner of the browser.

    The intention of the native handler is to hide some popup windows and other elements in the UI if Canvas.contains(Canvas) returns true. Don't know if this is the proper way as this code is a legacy thing. Any suggestions for the different approach are welcomed.


    1. v9.0p_2013-08-27/LGPL Development Only (built 2013-08-27)
    tested also with 2013-10-16 (4.1d) version

    2. Firefox 24.0 + Chrome 30.0.1599.101 were tested. Reported also from various IE browsers.

    The test case class TabsTestCase.java is just the simple subclass of EntryPoint with few lines of code. Everything else is basically default. No server-side code is involved.

    To fix the problem, it is enough to comment line 60 (Canvas target = EventHandler.getTarget();).

    Thank you in advance

    Lukas

    TabsTestCase.java
    Code:
    package com.mediasol.testcases.smartgwt.tabset.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.ui.RootLayoutPanel;
    import com.smartgwt.client.util.EventHandler;
    import com.smartgwt.client.widgets.Button;
    import com.smartgwt.client.widgets.Canvas;
    import com.smartgwt.client.widgets.Label;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.layout.HLayout;
    import com.smartgwt.client.widgets.tab.Tab;
    import com.smartgwt.client.widgets.tab.TabSet;
    
    public class TabsTestCase implements EntryPoint {
    	
    	@Override
    	public void onModuleLoad() {
    		initializeClickHandler();
    		
    		HLayout mainLayout = new HLayout();
    		mainLayout.setWidth100();
    		mainLayout.setHeight100();
    		
    		final TabSet tabSet = new TabSet();
    		
    		Tab tab1 = new Tab();
    		tab1.setCanClose(false);
    		tab1.setTitle("Tab 1");
    		Button myButton = new Button();
    		myButton.setTitle("Test Bug");
    		tab1.setPane(myButton);
    		tabSet.addTab(tab1);
    		
    		myButton.addClickHandler(new ClickHandler() {
    			
    			@Override
    			public void onClick(ClickEvent event) {
    				Tab tab2 = new Tab();
    				tab2.setCanClose(false);
    				tab2.setTitle("Tab 2");
    				Label myLabel = new Label("Test content");
    				tab2.setPane(myLabel);
    				tabSet.addTab(tab2);
    				tabSet.selectTab(tab2);
    			}
    			
    		});
    		
    		mainLayout.addMember(tabSet);
    		RootLayoutPanel.get().add(mainLayout);
    	}
    	
    	public static native void initializeClickHandler()/*-{
    		$wnd.globalClickHandler = @com.mediasol.testcases.smartgwt.tabset.client.TabsTestCase::globalClickHandler();
    		$wnd.isc.Page.setEvent("mouseDown", "globalClickHandler()");
    	}-*/;
    	
    	public static void globalClickHandler() {
    		Canvas target = EventHandler.getTarget(); // Comment this line to make it working again
    	}
    	
    }
    Attached Files

    #2
    This is a very very weird side effect and we'll check it out in case it reveals some kind of deeper issue.

    A generally better way of doing what you're trying to do is to use GWT's EventPreview APIs.

    Comment


      #3
      We've committed fixes to the SGWT 4.1d/4.0p branches to prevent the ID collision you observed. Check the next nightly build(s). This should restore correct function to your sample.

      Comment

      Working...
      X