Vaadin Tabs event issue

Hi, is there any way to get event about clicking on the already selected Tab? Event is only firing once the other tab is clicked …I want the event to be fired on the same tab as well…For eg if you are on X tab and you click again X tab the event should get fired.
Thank you

Hi dilip,

a possibility for solving your issue could be to define a Click event on the tabs.
So, every time the tabs component is clicked a handler method will be called.

Another approach is to attached the click event to each individual tab component. The method event-handler could be the same for all of them. This way, you will get an event every time you click on a tab.

Here, there is the vaadin tutorial about how to define the events and use them with components:
https://vaadin.com/docs/v10/flow/creating-components/tutorial-component-events.html

Here is an example of the second approach:

public class MyTab extends Tab {

    public MyTab(String s){
        super(s);
    }

    @DomEvent("click")
    public static class ClickTabEvent extends ComponentEvent<Tab> {

        public ClickTabEvent(Tab source, boolean fromClient) {
            super(source, fromClient);
        }
    }

    public Registration addClickListener(
            ComponentEventListener<ClickTabEvent> listener) {
        return addListener(ClickTabEvent.class, listener);
    }
}

Repository: https://github.com/DiegoSanzVi/tabs/tree/master/my-starter-project