cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Advocate V
Advocate V

Bug(?): Dropdown OnChange behavior not as expected.

I have global collections and variables that I use throughout my app, many of the screens manipulate the content and values of these. The OnChange property for dropdowns(with this collection as its items property or default) also set global variables, I do this so that screens across the app have the same default value when entering. The problem is that changes to the dropdowns Items or Default property triggers the OnChange, even for controls outside the apps active screen. This then cascades through my app and causes somewhat confusing results. This has not been much of an issue for me until recently.

 

It seems that I have not understood the documentation correctly, when expecting OnChange to trigger when the users changes the control:

Core properties in PowerApps

OnChange – How the app responds when the user changes the value of a control (for example, by adjusting a slider).

 

Either this is a bug that has been introduced in recent updates, or the documentation is unclear. But if the documentation means potentially any control instead of the control in "..user changes the value of a control ", it is pretty problematic in my opinion.

 

Anyone else experience similar problems or better ways to work around this?

Or if this is not a bug and the documentation is correct, can shed some light on my misconceptions to help me understand it better?

 

 

Assuming and hoping this is a bug, my workaround for this is wrapping a condition that checks if the active screen is the same as the controls parent screen, around the OnChange actions: 

 

If(App.ActiveScreen.Name = Parent.Name, Action1..; Action2..);

 

But I fear that this yet another workaround which is going to cause problems in future updates

PS
I tried this trick with DisplayMode, but it seems that OnChange triggers regardless of DisplayMode.

DisplayMode:

 

If(App.ActiveScreen.Name = Parent.Name, DisplayMode.Edit, DisplayMode.Disabled) 

 

 

It is possible this is is the case for other controls, but dropdown is the only one I have tested so far.

4 REPLIES 4
Dual Super User III
Dual Super User III

But if you change the value of default programmatically by changing something on another screen, it is still you as the user making a change.  So the OnChange event fires. Its not a bug.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Advocate V
Advocate V

Hm this is confusing to me @Pstork1 

Don't you think the documentation should mention this if this is the case? 
"the user changes the value of a control " To me that implies the value selected by the, user not that the state of the control itself has changed.


I did another experiment that now behaves as expected:
I have several dropdowns that change their own default variable with some pointless calculation:

 

 

Set(
varTestDefaultSelf,
Value(Text(Self.Selected.Value - 1))
);​

 


Their items is is a set of numbers:
2018,2019,2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,2035,2036,2037,2038,2039,2040,2041,2042

 

Each OnChange also adds an item to a collection

OnChangeLogic.gif

Why is only the one I change triggered this time?

 

Dual Super User III
Dual Super User III

The point is that you selected to change a control.  The fact that the change cascaded down to the drop down and changed its state doesn't change the fact that the change was originally initiated by you. I think you are misreading the documentation.  But I don't see any point in arguing about it.  I can't change the documentation or the behavior and neither can you.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Advocate V
Advocate V

I'm sorry if you thought I was arguing @Pstork1. I'm only trying to understand this to resolve some issues I'm having in the best way possible. Your initial reply did not fit with the outcome of my experiment, so I just wanted to understand why 🙂 That the state cascaded is not unexpected, but OnChange did not trigger in the experiment the way it does in my app (the issue I explained in the initial post)

 

It does not seem to always be the case that OnChange is triggered by changing the control's default variable. There must be another factor in place for this to happen. If this is not due to some bug and I knew that factor, I would be able to resolve my issue. 

 

We may not be able to change the documentation ourselves, but we may influence it by providing feedback 🙂

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (51,451)