Superset导航栏高亮问题处理


在superset => templates => appbuilder 文件夹下找到 navbar.html 如果没有可对应新建,navbar.html内容如下

{% set menu = appbuilder.menu %}
{% set languages = appbuilder.languages %}
{% set WARNING_MSG = appbuilder.app.config.get('WARNING_MSG') %}
{% set app_icon_width = appbuilder.app.config.get('APP_ICON_WIDTH', 126) %}
{% set logo_target_path = appbuilder.app.config.get('LOGO_TARGET_PATH') or '/profile/{}/'.format(current_user.username) %}



<script>
// Highlight the navbar menu
const menus = document.querySelectorAll('.nav.navbar-nav li')
for (const menu of menus.values()) {
  const classes = menu.getAttribute('class')
  const as = menu.querySelectorAll('a')
  for (const a of as.values()) {
    const href = a.getAttribute('href')
    let path = location.pathname
    if (path.indexOf(href) > -1) {
      menu.setAttribute('class', `${classes} active`)
    } else {
      menu.setAttribute('class', `${classes}`)
    }
  }
}
</script>

存在的问题:带有下拉菜单的不能高亮