Currently focused component/element?

Is there a way to get the currently focused component/element? I don’t see any methods in either UI or Page class.

I tried to track the focus by adding an event listener to the layout’s element. But, I can’t get the element somehow (It’s throwing an error:
(String) : Message JsonObject contained a dom node reference which should not be sent to the server and can cause a cyclic dependecy.
Code I tried is as follows:

getElement().addEventListener("focusin", this::focusGot).addEventData("event.target");

private void focusGot(DomEvent event) {
	JsonObject e = event.getEventData();
	//Notification.show(e.asString());
}

There’s no built-in functionality for tracking generic focus changes and sending that information to the server. You can still listen to focus and blur listeners for specific elements by adding an listener to each element that you’re interested in.

There is no support for sending something like “event.target” as an event data value to the server since it might refer to elements that the server-side doesn’t even know anything about. We might consider e.g. sending null or traversing parent elements until finding one that the server tracks, but there’s no such feature at the moment.

Hi Leif, thanks for the response.
Looking at the DOM while running, I can see that an attribute named “focused” is set on the currently focused element. However, I am unable to get that info too at the server side.