Autofocus on textinput


I want to switch between two containers. One is displayed as a button, and when it is clicked, I want it to change to a text input where the user can create their own button.

I am using conditional styling to control which one is visible and want to trigger autofocus on the text input when they switch. It seems there is no autofocus option in the conditional styles. Is there a way to manipulate this attribute conditionally?



Is it correct that you want the following?

  1. A Text Edit visible by default, but without autofocus
  2. Given some condition, you want to make that Text Edit have autofocus turned on

If that is the case: The browser/autofocus feature only allows the focus to be set automatically as soon as the component is rendered. That means: You would need 2 Text Edits: One without autofocus, visible given condition 1), and another Text Edit with autofocus, visible given condition 2). As soon as condition 2) is true, the second Text Edit is made visible and gets focus.