fix: admin sidebar missing on /admin/my-menu page
Rename loadMenuConfig() → loadUserMenuConfig() in adminMyMenuConfig() to avoid shadowing the sidebar's loadMenuConfig() inherited from data() via the spread operator. The name collision caused the sidebar to never populate its menuData, showing only the fallback "Dashboard" link. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,16 +1,10 @@
|
||||
// static/admin/js/my-menu-config.js
|
||||
// Personal menu configuration for super admins
|
||||
//
|
||||
// TODO: BUG - Sidebar menu doesn't update immediately after changes.
|
||||
// User must navigate to another page to see the updated menu.
|
||||
// The issue is that Alpine.js doesn't properly track reactivity for the
|
||||
// visibleMenuItems Set in init-alpine.js. Attempted fixes with reloadSidebarMenu()
|
||||
// and window.location.reload() didn't work reliably.
|
||||
// Possible solutions:
|
||||
// 1. Convert visibleMenuItems from Set to plain object for better Alpine reactivity
|
||||
// 2. Use Alpine.store() for shared state between components
|
||||
// 3. Dispatch a custom event that the sidebar listens for
|
||||
// 4. Force re-render of sidebar component after changes
|
||||
// NOTE: The page method for loading user menu config is named loadUserMenuConfig()
|
||||
// (not loadMenuConfig()) to avoid shadowing the sidebar's loadMenuConfig() inherited
|
||||
// from data() via the spread operator. Shadowing caused the sidebar to never populate
|
||||
// its menuData, resulting in a blank sidebar on this page.
|
||||
|
||||
const myMenuConfigLog = window.LogConfig?.loggers?.myMenuConfig || window.LogConfig?.createLogger?.('myMenuConfig') || console;
|
||||
|
||||
@@ -71,7 +65,7 @@ function adminMyMenuConfig() {
|
||||
try {
|
||||
// Load core translations for confirmations
|
||||
await I18n.loadModule('core');
|
||||
await this.loadMenuConfig();
|
||||
await this.loadUserMenuConfig();
|
||||
myMenuConfigLog.info('=== MY MENU CONFIG PAGE INITIALIZED ===');
|
||||
} catch (error) {
|
||||
myMenuConfigLog.error('Failed to initialize my menu config page:', error);
|
||||
@@ -82,10 +76,10 @@ function adminMyMenuConfig() {
|
||||
async refresh() {
|
||||
this.error = null;
|
||||
this.successMessage = null;
|
||||
await this.loadMenuConfig();
|
||||
await this.loadUserMenuConfig();
|
||||
},
|
||||
|
||||
async loadMenuConfig() {
|
||||
async loadUserMenuConfig() {
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user