logo
search
list

Table of Content

Diagnostic Checks for Modern Component Rendering
Implementing the Timer Delay Workaround
Using the Attachment Control Context Method
Alternative: Reverting to Classic Text Inputs
Documenting App Architecture with WPS Office
Frequently Asked Questions

How to Fix SetFocus Not Working with Modern Text Input in Power Apps

Posted by Bushra Parveen

calendar

2026-09-08

views

869

likes

4

When building canvas apps, directing user attention is critical for a smooth user experience and efficient data entry. However, developers adopting the latest Fluent UI elements often encounter a frustrating roadblock: the focus function simply ignores the target component. If you are working to fix SetFocus not working with modern text input in Power Apps, you are dealing with a known rendering behavior difference between classic and modern controls. Because modern components load asynchronously, standard functions triggered during screen transitions often fire before the component actually exists on the screen. This guide walks you through actionable diagnostic checks and practical Power Fx workarounds to restore expected form behaviors.

Diagnostic Checks for Modern Component Rendering

Before applying a fix, you must confirm that the issue is tied to the modern control's lifecycle rather than a logical error in your Power Fx formula. Modern controls handle the Visible and DisplayMode properties differently than classic controls.

  • Check the Display Mode: Ensure your target modern text input is set to DisplayMode.Edit. The SetFocus command will silently fail if the control is in View or Disabled mode when the function executes.
  • Verify Visibility Timing: If your control is hidden behind a variable (e.g., Visible = locShowInput), triggering SetFocus in the exact same concurrent batch as the visibility toggle will fail. The control must be fully rendered first.
  • Inspect Container Nesting: Modern controls placed deeply inside Galleries, scrollable screens, or custom components have delayed initialization. Attempting to set focus from an external screen's OnVisible property will not reach the nested modern control in time.

Implementing the Timer Delay Workaround

The most reliable method to solve fixing SetFocus Not Working with Modern Text Input in Power Apps is introducing a micro-delay. This gives the application engine enough time to render the Fluent UI component before attempting to place the cursor inside it. You can achieve this using a hidden Timer control.

Follow these sequential actions to implement the timer delay:

  1. Navigate to the screen containing your modern text input and insert a standard Timer control from the Insert menu.
  2. Select the Timer control and change its Visible property to false so it does not clutter your user interface.
  3. Set the Duration property to 100 (milliseconds). This is usually fast enough to be unnoticeable to the user but slow enough to allow the modern text input to load.
  4. Set the AutoStart property of the Timer to your triggering variable, for example, locTriggerFocus.
  5. In the Timer's OnTimerEnd property, input your focus command: SetFocus(YourModernTextInputName). Immediately follow it with a command to reset the variable: UpdateContext({locTriggerFocus: false}).
  6. Finally, on your submit button or screen OnVisible property where you originally had the SetFocus command, replace it with: UpdateContext({locTriggerFocus: true}).

Verify this by navigating away from the screen and returning. The cursor should now successfully blink inside the target modern text field after a fractional delay.

Using the Attachment Control Context Method

Illustrated steps for Fixing SetFocus Not Working with Modern Text Input in Power Apps
Key actions for Fixing SetFocus Not Working with Modern Text Input in Power Apps.

If you are working inside an Edit Form and wish to avoid adding timers, you can leverage the form's internal rendering lifecycle. Modern controls inside forms sometimes require a context shift to recognize focus commands.

Select your screen and locate the OnVisible property. Instead of calling the control directly, wrap the command in a concurrent function that evaluates the form mode first. Use the formula: Concurrent(ResetForm(YourFormName), SetFocus(YourModernTextInputName)). If the control is nested inside a gallery, you must use the select parent command first. Add a hidden button inside the gallery template, set its OnSelect property to SetFocus(YourModernTextInputName), and trigger that hidden button from outside the gallery using the Select() function. This forces the context to shift into the specific gallery row before applying the focus command.

Alternative: Reverting to Classic Text Inputs

When working with highly complex applications where micro-delays cause unacceptable performance stuttering, or when building custom components where timer controls are not supported, the only genuinely effective alternative is substituting the modern control. Modern controls are continually updated, but if strict accessibility compliance mandates instant cursor focus on load, classic controls remain structurally simpler and fully synchronous.

Delete the modern text input from your canvas. Go to the Insert menu, search for Text input (Classic), and place it on your screen. Update your styling properties (such as BorderColor, Radius, and Font) to mimic the Fluent UI design language. Because classic controls render synchronously with the screen load, your original SetFocus(ClassicTextInputName) command placed in the screen's OnVisible property will execute correctly without any timers or context variables.

Documenting App Architecture with WPS Office

WPS Office options related to Fixing SetFocus Not Working with Modern Text Input in Power Apps
How WPS Office can support related document work.

While testing various workarounds for fixing SetFocus Not Working with Modern Text Input in Power Apps, maintaining clear documentation of your experimental Power Fx code and component changes is essential for version control and team collaboration. Because Power Apps does not natively export component property logs, developers often need an external suite to manage technical documentation and app schemas.

WPS Office provides an incredibly lightweight and broadly compatible environment for this exact task. You can use WPS Writer to draft your app architecture documents. If you are comparing rendering times between classic and modern controls, paste your code snippets into WPS Writer; its formatting tools handle plain text code cleanly without forcefully applying unwanted rich-text formatting that breaks syntax.

Additionally, if your modern text inputs are writing data back to complex SharePoint or Dataverse tables, use WPS Spreadsheet to map out your data schema. You can easily track which columns are connected to which modern controls. When sharing your troubleshooting steps with stakeholders or Microsoft support, use the built-in PDF export tool in WPS Office to instantly convert your Writer or Spreadsheet documentation into a secure, universally readable PDF file. The integrated AI features in WPS can also help you summarize lengthy technical notes into concise troubleshooting steps for your internal team wiki.

WPS Writer app icon
WPS Presentation app icon
WPS Spreadsheets app icon
WPS PDF app icon
Use Word, Excel, and PPT for FREE

Frequently Asked Questions

Why does the focus command execute correctly on classic components but fail on newer UI elements?

Classic components in canvas apps are evaluated and rendered synchronously as the screen loads. The newer Fluent UI components are built on a different framework designed for performance and responsiveness, meaning they render asynchronously. When the screen loads, the focus formula fires before the asynchronous rendering of the new component is fully completed, causing the application engine to lose the target.

Can I trigger cursor placement on a modern input inside a Gallery control?

Yes, but it requires targeting the specific row context. You cannot point directly to a component inside a gallery from the screen level. You must first set a variable indicating the active gallery row, use the Select function to shift the app's context to that specific row, and then utilize a hidden timer within the gallery template to fire the command once the row's components are fully initialized.

Does adding timer controls for UI delays impact overall application performance?

Adding a single timer with a 100-millisecond duration to handle initialization delays has a negligible impact on performance. However, if you place timers inside a gallery template that contains hundreds of rows, the application will instantiate hundreds of hidden timers, which will severely degrade browser memory and app responsiveness. In gallery scenarios, rely on hidden buttons and the Select function instead.

Is this rendering behavior a permanent feature or a known bug?

Microsoft treats the asynchronous rendering of modern components as an intentional architectural design to improve overall app load times, rather than a bug. However, the lack of a native "OnRenderComplete" property that developers can hook into for tasks like cursor placement is a recognized limitation. Until Microsoft provides a native callback property for Fluent UI elements, developers must continue relying on state variables or delay tactics.

Bushra Parveen

I simplify tech—especially Office tools—so anyone can use it confidently. For 5+ years, I've created clear how-tos & guides to make tech feel easy, not overwhelming. Follow for practical tips!