Automatically focus on visible

Is there a way to automatically place focus on a text field when something becomes visible in the viewport? I have tried to set the state to Focus but since that is a default state, it does not work. Do I need to create a custom state “Focus” and use an action or is there a more standard way to achieve this?
Autofocus

I don’t think you can do this with Antetype controls, because it is not possible to apply focus() to text elements that are editable in the prototype.

Working with a native HTML input tag + focus() could accomplish this.

Ok, thanks, I’ll try that.

looks like it works in a little bit hacky way:

focus 2 2.zip (291.9 KB)

The trick is to focus the inner span:

let element = targetCells[0].DOMElement;   

let textSpan = element.querySelector("span > span");   
textSpan.focus();

Did not know it that this is possible, but seems to work in Chrome/Safari/Firefox

1 Like

Brilliant. It also works with “Visible in Viewport”. Sweet, thanks so much!

1 Like