This behavior is a known timing issue in Power Apps, not a problem with formula. SetFocus() works reliably in Preview (F5) but can intermittently fail in the published app because of how Power Apps renders controls. Why this happens, because In Preview mode, screens and controls load more predictably. But in the published app, screens render faster and asynchronously.
SetFocus() executes before the TextInput control is fully rendered and when the control is not yet rendered, Power Apps silently ignores the focus request. This results in intermittent behavior (for example, failing 20% of the time).
- Important limitation of SetFocus() SetFocus() only works when: 1)The control is already rendered 2)The control is visible and enabled 3)If these conditions are not met at execution time, focus will not be applied.
- Recommended & Practical Solution Use a hidden Timer to delay SetFocus, this is the most stable approach for published apps. Steps: 1)Add a Timer control with Duration: 300 (increase to 400–500 ms if needed) 2)AutoStart: false 3)Repeat: false 4)Visible: false 5)Screen → OnVisible 6)Reset (Timer1) 7)Start (Timer1) 8)Timer → OnTimerEnd 9)SetFocus(TextInput1)
Why this works: The timer ensures the screen and controls are fully rendered before calling SetFocus().
- Alternative Approaches Using a variable-based delay :- Set(varFocus, true) Then trigger SetFocus() based on user interaction or another control’s event. This may work in some cases but is not as reliable as the timer.
Hope this helps.
Thanks!
Inogic
Was this reply helpful?YesNo
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.