Skip to content

Commit

Permalink
Avoid empty menus spawning empty panel (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
milewski authored Oct 13, 2023
1 parent 7fba56e commit 89969c2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/js/tool.js

Large diffs are not rendered by default.

26 changes: 19 additions & 7 deletions resources/js/components/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</div>

<div class="bg-[rgba(var(--colors-gray-50))] dark:bg-[rgba(var(--colors-gray-900),.65)] lg:dark:bg-[rgba(var(--colors-gray-500),.05)] transition-width duration-300 flex overflow-x-hidden relative"
:class="{
:class="{
'w-[240px] border-r border-gray-200 dark:border-gray-700': screen === 'desktop' && currentActiveMenu,
'w-full dark:border-r dark:border-gray-700': screen === 'responsive',
'w-[0px] border-transparent': currentActiveMenu === null,
Expand Down Expand Up @@ -78,6 +78,7 @@
import UserMenu from '../native/UserMenu.vue'
import SvgIcon from './SvgIcon.vue'
import MenuSection from './MenuSection.vue'
import cloneDeep from 'lodash/cloneDeep'
export default {
props: [ 'screen', 'NotificationCenter', 'ThemeDropdown' ],
Expand Down Expand Up @@ -118,7 +119,23 @@
return this.recursiveFind(this.menus)
},
menus() {
return this.$store.getters[ 'mainMenu' ]
/**
* For whatever reason, laravel nova sometimes returns some menu items with null items within...
* so this filter them out to avoid the panel expanding blank
*/
const menus = cloneDeep(this.$store.getters[ 'mainMenu' ])
for (const menu of menus) {
if (menu.items.length) {
menu.items = menu.items.filter(item => item.component !== null)
}
}
return menus
},
notificationCenterEnabled() {
return Nova.config('notificationCenterEnabled')
Expand Down Expand Up @@ -278,9 +295,4 @@
}
#collapsible-resource-manager-responsive ~ div{
background-color: red !important;
}
</style>

0 comments on commit 89969c2

Please sign in to comment.