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
|
// static/admin/js/my-menu-config.js
|
||||||
// Personal menu configuration for super admins
|
// Personal menu configuration for super admins
|
||||||
//
|
//
|
||||||
// TODO: BUG - Sidebar menu doesn't update immediately after changes.
|
// NOTE: The page method for loading user menu config is named loadUserMenuConfig()
|
||||||
// User must navigate to another page to see the updated menu.
|
// (not loadMenuConfig()) to avoid shadowing the sidebar's loadMenuConfig() inherited
|
||||||
// The issue is that Alpine.js doesn't properly track reactivity for the
|
// from data() via the spread operator. Shadowing caused the sidebar to never populate
|
||||||
// visibleMenuItems Set in init-alpine.js. Attempted fixes with reloadSidebarMenu()
|
// its menuData, resulting in a blank sidebar on this page.
|
||||||
// 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
|
|
||||||
|
|
||||||
const myMenuConfigLog = window.LogConfig?.loggers?.myMenuConfig || window.LogConfig?.createLogger?.('myMenuConfig') || console;
|
const myMenuConfigLog = window.LogConfig?.loggers?.myMenuConfig || window.LogConfig?.createLogger?.('myMenuConfig') || console;
|
||||||
|
|
||||||
@@ -71,7 +65,7 @@ function adminMyMenuConfig() {
|
|||||||
try {
|
try {
|
||||||
// Load core translations for confirmations
|
// Load core translations for confirmations
|
||||||
await I18n.loadModule('core');
|
await I18n.loadModule('core');
|
||||||
await this.loadMenuConfig();
|
await this.loadUserMenuConfig();
|
||||||
myMenuConfigLog.info('=== MY MENU CONFIG PAGE INITIALIZED ===');
|
myMenuConfigLog.info('=== MY MENU CONFIG PAGE INITIALIZED ===');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
myMenuConfigLog.error('Failed to initialize my menu config page:', error);
|
myMenuConfigLog.error('Failed to initialize my menu config page:', error);
|
||||||
@@ -82,10 +76,10 @@ function adminMyMenuConfig() {
|
|||||||
async refresh() {
|
async refresh() {
|
||||||
this.error = null;
|
this.error = null;
|
||||||
this.successMessage = null;
|
this.successMessage = null;
|
||||||
await this.loadMenuConfig();
|
await this.loadUserMenuConfig();
|
||||||
},
|
},
|
||||||
|
|
||||||
async loadMenuConfig() {
|
async loadUserMenuConfig() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user