Oracle APEX Navigation Menu Issue (Query-Based Menu Collapse Problem)

 Here is a ready-to-use BLOG CONTENT for Oracle APEX (Menu Issue + Solution). You can directly paste this into APEX HTML region / Rich Text / Static Content.


🧭 Oracle APEX Navigation Menu Issue (Query-Based Menu Collapse Problem)

📌 Problem Statement

In Oracle APEX 23.2, when using a query-based navigation menu (tree menu):

  • The dropdown menu opens correctly on click
  • But when a submenu page is selected
  • ❌ The menu collapses automatically
  • ❌ Parent menu does not stay expanded
  • ❌ User loses navigation context after page load

This happens because the menu is rebuilt dynamically from SQL on every page refresh.


⚠️ Root Cause

The issue occurs because:

  • The menu is query-based (dynamic tree)
  • APEX does NOT know which item is currently active
  • Your query is returning static value:
'NO' is_current

So APEX cannot mark the current page in the navigation tree.


🧩 Original Query (Problematic)

select level, 
NAME label,
decode(pageID, null, null, 'f?p=&APP_ID.:'||PAGEID||':&APP_SESSION.') as target,
'NO' is_current,
'>>' image
from VMENUTREES
WHERE USER_TYPE=
(SELECT USERTYP FROM APPSUSERS WHERE LTRIM(RTRIM(USERNAME))=LTRIM(RTRIM(:APP_USER)))
start with PARENT is null
connect by prior LTRIM(RTRIM(CODE))=LTRIM(RTRIM(PARENT))
AND PRIOR USER_TYPE=
(SELECT USERTYP FROM APPSUSERS WHERE LTRIM(RTRIM(USERNAME))=LTRIM(RTRIM(:APP_USER)))
order siblings by PARENT_SL,SL

✅ Solution (Fix Menu Collapse Issue)

🔥 Step 1: Fix CURRENT PAGE IDENTIFICATION

Replace 'NO' is_current with:

CASE 
WHEN PAGEID = :APP_PAGE_ID THEN 'YES'
ELSE 'NO'
END is_current

✅ Fixed Query

SELECT LEVEL, 
NAME LABEL,
DECODE(PAGEID, NULL, NULL,
'f?p=&APP_ID.:'||PAGEID||':&APP_SESSION.') AS TARGET,

CASE
WHEN PAGEID = :APP_PAGE_ID THEN 'YES'
ELSE 'NO'
END AS IS_CURRENT,


'>>' IMAGE
FROM VMENUTREES
WHERE USER_TYPE =
(SELECT USERTYP
FROM APPSUSERS
WHERE TRIM(USERNAME) = TRIM(:APP_USER))

START WITH PARENT IS NULL
CONNECT BY PRIOR TRIM(CODE) = TRIM(PARENT)
AND PRIOR USER_TYPE =
(SELECT USERTYP
FROM APPSUSERS
WHERE TRIM(USERNAME) = TRIM(:APP_USER))

ORDER SIBLINGS BY PARENT_SL, SL;

🚀 Step 2: Ensure Parent Menu Stays Open (Optional Fix)

Add this JavaScript in:

👉 Page 0 (Global Page)Execute When Page Loads

$(".is-current")
.closest(".a-TreeView-node")
.parents(".a-TreeView-node")
.attr("aria-expanded", "true");

🎯 Result After Fix

✔ Active page is detected
✔ Parent menu stays expanded
✔ No unwanted collapse
✔ Better UX navigation
✔ Works across all pages (global fix)


💡 Pro Tip (Best Practice)

If possible:

  • Always map PAGEID correctly
  • Avoid static 'NO' is_current
  • Use :APP_PAGE_ID for dynamic navigation state

🏁 Conclusion

This issue is common in query-based Oracle APEX menus, but it is easily solved by:

✔ Correct is_current logic
✔ Proper tree expansion handling




Muhammad Abdullah Al Noor

Muhammad Abdullah Al Noor, An Oracle Apex Consultants and founder of Noors Technology (www.noorstech.com). Core Expertise : Database Administration, Oracle Forms and Reports Development, Oracle Apex Application Designer and Development, Linux Professional etc. Also the owner of TrainerBD Training and OraDemy E-Learning. WhatsApp +8801790721177

Post a Comment

Previous Post Next Post