vaadin/vaadin-tabs-flow

Tab selection from the server-side should fire a server-side event

Closed this issue · 2 comments

Selecting a tab with Java currently fires an event with isFromClient = true

Context (internal)

I don't think this is a bug.

There is a confusion and I've already fixed this via javadocs.

As I understand you are talking about addSelectedChangeListener and SelectedChangeEvent.

This is the declaration of the SelectedChangeEvent class:

@DomEvent("selected-changed")
    public static class SelectedChangeEvent extends ComponentEvent<Tabs> {
        public SelectedChangeEvent(Tabs source, boolean fromClient) {
            super(source, fromClient);
        }
    }

So it's a DOM event. DOM event is always fired from the client side.

If you want an event from the server side then you should listen selected property value.

This is javadocs which I've added:
https://github.com/vaadin/vaadin-tabs-flow/blob/master/src/main/java/com/vaadin/flow/component/tabs/Tabs.java#L107

pekam commented

So it's a DOM event. DOM event is always fired from the client side.

We should provide a way for users to listen for selection changes both from client and server. This is expected based on the API. The fact that it is a DomEvent is an implementation detail.

Having confusing API that doesn't follow the conventions is a bug. Here's the fix: #68