🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Autofocus
This page was created by Lars.olofsson on 2021-06-24. Last edited by Wikiadmin on 2026-07-29.

You can use the autofocus tagged value to place the cursor in a chosen input field when that field appears in a view; use it when users should start typing immediately.

How autofocus works

Set the tagged value autofocus to true on the input field that should receive focus. When the field is rendered, MDriven moves focus to that input.

This is useful in data-entry views where the user repeatedly creates records. For example, if an editable table has an action that adds a new row for a number, configure the number input with autofocus = true. After the new row appears, the user can continue entering the next number without selecting the cell manually.

Add autofocus to an input field

  1. Open the relevant ViewModel in MDriven Designer.
  2. Select the input field that should receive focus when it appears.
  3. Add the tagged value autofocus to the field.
  4. Set the tagged-value value to true.
  5. Save the ViewModel and run the view.
  6. Confirm that the cursor is placed in the configured field when the field or a new editable row appears.

Example: focus the first editable value in a new row

Assume a view contains an editable table of number entries and an action that adds a row.

  1. Configure the table's number input with autofocus = true.
  2. Run the view and use the action that creates a row.
  3. When the new row is displayed, focus moves to the number input in that row.
  4. Type the number directly.

The rendered column behavior is described in Documentation:Column.autofocus.

Tagged-value template

The autofocus tagged-value template must be available in your MDriven Designer installation before you can apply this setting. Update MDriven Designer from the wiki to obtain the template if it is not available.

Use autofocus deliberately

Autofocus changes where keyboard input begins. Apply it to the field that represents the next expected user task. In an editable table, this is typically the value field in the newly created row rather than a field the user rarely changes.

Related field settings

Use Column.Texttype when you need to control the HTML input type. Autofocus controls initial focus; it does not define the input type.

See also