TextField.focus not working in a view.

I have a fairly simply view which I’m naviaging to via ‘navigateTo’.

In the viewComponent method I build the UI if it hasn’t already been built.

In the enter method I’m call the TextField .focus method on a TextField that is in the view (via a Vertical layout).

The problem is that when the view opens the textfield doesn’t have the focus.

At what point in the process should I be setting the focus?
Is there anything special I have to do to make the text field focusable?

I’m running vaadin 8.3 but I’ve had the same problems in all vaadin 8 releases.

    public void enter(ViewChangeEvent event)
    public Component getViewComponent()

     void buildUI()
            gardenBedName = new TextField("Label");
            topLine.setComponentAlignment(gardenBedName, Alignment.MIDDLE_LEFT);

Hi, I did a quick test and enter() seems to be a good time for the focus method.

What may be causing your issues is that you are building the view by hand on each getViewComponent() call. Instead, try calling your buildUI() method on instantiation (in the constructor) and do not override the getViewComponent() mehtod. This will work nicely if your view extends a Component, such as a layout. You can find an example of a view [in the docs]