Issue with disabled Tab in TabSheet

Hi,

I have tried this code with Vaddin versions : 7.1.10, 7.1.12 and 7.1.14

I have a Tabsheet with 5 tabs added to it. Tabs at position 1 and 3 are disabled.
Issue I see here is when I click on disabled tab it navigates back to tab at position 0 (basically it navigates back to enabled tab with least position)

Expectation is that SelectedTabChangeEvent should not be fired if the tab is disablled.

Can you please help me understanding if I am missing anything here or is it bug with Vaadin and how this tabsheet behavior can be controlled.

Following is the code for reference:

public class TabsheetDemo extends UI {

    @Override
    protected void init(VaadinRequest request) {
        final VerticalLayout vLayout = new VerticalLayout();
        final TabSheet tabsheet = new TabSheet();
        
        final VerticalLayout tab1 = new VerticalLayout();
        final VerticalLayout tab2 = new VerticalLayout();
        final VerticalLayout tab3 = new VerticalLayout();
        final VerticalLayout tab4 = new VerticalLayout();
        final VerticalLayout tab5 = new VerticalLayout();
        
        tab1.addComponent(new Label("Label A"));
        tab2.addComponent(new Label("Label B"));
        tab3.addComponent(new Label("Label C"));
        tab4.addComponent(new Label("Label D"));
        tab5.addComponent(new Label("Label E"));
        
        tabsheet.addTab(tab1,"Tab 1");
        tabsheet.addTab(tab2,"Tab 2");
        tabsheet.addTab(tab3,"Tab 3");
        tabsheet.addTab(tab4,"Tab 4");
        tabsheet.addTab(tab5,"Tab 5");    
        
        tabsheet.getTab(1).setEnabled(false);
        tabsheet.getTab(3).setEnabled(false);    

        tabsheet.addSelectedTabChangeListener(new SelectedTabChangeListener() {            
            @SuppressWarnings("deprecation")
            @Override
            public void selectedTabChange(SelectedTabChangeEvent event) {
                //System.out.println("getTabPosition = "+tabsheet.getTabPosition(tabsheet.getTab(tabsheet.getSelectedTab())));
                UI.getCurrent().showNotification("Selected tab position : "+tabsheet.getTabPosition(tabsheet.getTab(tabsheet.getSelectedTab())));
            }
        });
        
        vLayout.setHeight("100px");
        vLayout.addComponent(tabsheet);
        
        setContent(vLayout);
    }
}

Regards,
Kunal Patil

Could be related to this ticket that I submitted awhile ago that hasn’t been fixed.

http://dev.vaadin.com/ticket/12123

-Dan

Hey Kunal, you are doing nothing wrong, Vaadin handles it internally in that way, “The first visible and enabled tab is selected if the current selection is empty or invalid.”, you can check it from the updateSelection in Tabsheet class. this can be helpful and makes sense, for example when the selected Tab is removed.

I would say your argument makes sense, that is, when the tab is disabled, I think it’s better to not fire the SelectedTabChangeEvent at all. So maybe you can help to file a ticket about this?

Thanks for your inputs Dan Nelson and Haijian Wang.
I have created a ticket regarding this issue :
http://dev.vaadin.com/ticket/13639

Regards,
Kunal Patil

The issue in discussion has been resolved with Vaadin version 7.2.0

Regards,
Kunal Patil