cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Digital
Super User
Super User

Gallery Fields Lose Focus OnChange

I am using a gallery to capture line items. I would like the OnChange of the text fields to update a collection. The problem is when tabbing or clicking to the next field, the OnChange fires and the field loses focus. This doesn't make for a nice user experience because the user needs to click in the box a second time.

 

Digital_0-1635396234898.png

There is a way round this by using ForAll on Gallery.AllItems in my save button to patch the collection. Unfortunately Power Apps doesn't allow me to access the text input values if the text inputs are in layout containers within the gallery (which mine are). I could re-do my gallery without containers but this will be very time consuming and not very flexible if I want to make changes to layout, add new fields etc.

 

Wondering if anyone has encountered this and know of a solution.

 

5 REPLIES 5
vermaaman
Resolver I
Resolver I

@Digital if your combobox is outside of gallery then you can use SetFocus onChange.

@vermaaman , unfortunately it needs to be inside a gallery as it is for collecting repeating lines of data. Looks like I'll need to ditch the layout containers and use ForAll with Gallery.AllItems to patch the values after they've been entered.

Wouter_K
Frequent Visitor

@Digital Hi, did you ever find a solutions without loosing the layout container?

 

Any reply is greatly appreciated.

@Wouter_K , There is a workaround that enables you to keep the layout containers in the gallery. You to create a duplicate collection and update this in the OnChange. This gets around the field losing focus on tab but introduces the added complexity of dealing with a duplicate collection.

beejo
Frequent Visitor

I ran into this too, and the second Collection workaround seems to be working well.  For anybody needing more explicit instructions, see: www.reddit.com/r/PowerApps/comments/uj7k4d/losing_focus_on_item_within_gallery/

 

I called them a "read" collection (what the gallery displays and what new entries go into) and a "write" collection (which is what I'm updating on gallery changes).  Data flows from data source to "read" to "write" back to data source.

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (3,074)