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.

    @Override
    public void enter(ViewChangeEvent event)
    {
        SmartView.super.enter(event);
        gardenBedName.focus();
    }
    @Override
    public Component getViewComponent()
    {
        buildUI();

     void buildUI()
     {
            gardenBedName = new TextField("Label");
            topLine.addComponent(gardenBedName);
            topLine.setComponentAlignment(gardenBedName, Alignment.MIDDLE_LEFT);
            gardenBedName.setWidth("100%");
            gardenBedName.setStyleName("i4p-label");
            Responsive.makeResponsive(gardenBedName);

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]
(https://vaadin.com/docs/framework/advanced/advanced-navigator.html).