Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Autocomplete field in Apex 20.1 - Custom change event issue

Leon_MNov 8 2023 — edited Nov 9 2023

Hello,

We have an Interactive Grid with a column defined as Text field with autocomplete.
We use our custom change event to validate user's input.
The change event uses data.optionMetadata.trigger to determine that selection was made.
It works fine for most of the time but sometimes fails when user types in the value and then clicks out of the field.
The data.optionMetadata.trigger returns undefined in this case. The issue is sporadic.

Here is the code of our change event function:

function isAcChanged(acItemId) {
 var validateInd = 'N';
 var objectInd = false;
 var currValue = acItemId.data.value;
 var prevValue = acItemId.data.previousValue;  

 //..fix for backspace key.....................................................  
 if ( (currValue === '' || currValue === undefined) && ( prevValue !== '' || prevValue !== undefined )) {
   if ( currValue !== prevValue ) {
     return true;
   }
 }  
 //..............................................................................
 if ( typeof acItemId.data.value === 'object' && acItemId.data.value !== null) {
   objectInd = true;
 }
 //..............................................................................
 if (acItemId.data.optionMetadata.trigger === 'option_selected'){ //click on lov value or enter key
   validateInd = 'Y'
 } else if (acItemId.data.optionMetadata.trigger === 'enter_pressed'){ //enter key without scrolling 
     validateInd = 'Y'      
 } else if (acItemId.data.optionMetadata.trigger === 'blur'){ //tab out, click out (loose focus)
     validateInd = 'Y'
 }  
 if ( validateInd === 'Y' ) {
   return true;      
 } else {
     return false;
 }
}

The function is called by Dynamic Action with ojoptionchange Custom Event. The DA is passing the object (this) of the triggering element to the change event function.

Clicking out of the field suppose to result in acItemId.data.optionMetadata.trigger === 'blur' but it is not always the case. Sometimes it results in undefined

How else can we capture the blur (loose focus) event inside our function?

We are in Apex 20.1

Thanks!

Comments
Post Details
Added on Nov 8 2023
1 comment
135 views