Tuesday, 16 February 2021

APEX 20.2 - radio item issue

Unusual radio item DA behavior in APEX 20.2 - bug!??

JavaScript Dynamic action on radio item stops working as expected


Yet another post touching on naming standards causing issues in APEX 20.2. I was asked to help by a client that stumbled on this issue and I wanted to share it here. 
 
Scenario is simple let's say you create a blank page like below.
 

So all we have on this page is simple region with two radio buttons.

If you run the page and click on your radio items all should work fine. Easy enough to do and expected behavior since we did not add any logic to it yet.
 
Please notice here the unconventional naming standard we are using here for these items PX_100 and PX_100_1. Keep in mind that this would not be a recommended way to name your items.

All good, let's now add a simple on change Javascript Dynamic Action on PX_100_1 item which will alert some text for us like "Hello world".
We are keeping it simple to make the point here...

Save and run the page. This part now depends on how complex your DA is but expected behavior in this example would be that we get alert messages when we keep clicking and changing values on PX_100_1 item, wouldn't it.
 
But wait this is not what happens. 
 
Firstly actual action triggers on my first element which is weird plus it does not do it on every change I make on that same item which we would also expect.
What you can also experience is that your cursor gets refocused as result of your action (or something very similar usually) causing your DA not to act as you would expect.

Why is this and where does it come from? Notice how second item on the page has very similar name to first item and that they both have only numbers in their names which then somehow causes an issue with DA selectors and listeners.

Fixing this issue is simple - simply rename your items for example PX_X100_1 would resolve the problem.

Try it for your self here
 
As you see this example is running on apex.oracle.com which should have all the latest patches applied.
 
Should APEX handle this situation a little bit better is a good question but hey having a good naming standard in place would help you too. :)

This was not happening on APEX 20.1 as far as I know so please keep an eye for it. 
 
Good thing is that 99.9% of your apps will not hit this use case so there is very little to worry about. :D


Happy APEXing,
Lino