Skip to content

observe not working with repeat #6850

Open
@vasicvuk

Description

@vasicvuk

🐛 Bug Report

I created a simple navigation component containing _menuItems array:

export const template = html<Navbar>`
  <div id="nav-content" class="${x => { return x.open === true ? '' : 'closed' }}">
   ${repeat(x => x._menuItems,
      html<MenuItem, Navbar>`
        <router-link path="${x => x.route}" >
          <div class="${x => x.active ? 'selected' : ''}" >
            <div class="nav-button">
              <asee-icon name="${x => x.icon}"></asee-icon>
              <span>${x => x.title}</span>
            </div>
          </div>
        </router-link>`
  )}
  </div>`

Since I want to observe the properties of the objects in code when I am loading the menu items list I set it like this:

this._menuItems = menuItemsLoader.menuItems.map(x => reactive(x));

Then i have the method which changes the active property on the route change:

public activateRoute() {
    for (let menuItem of this._menuItems) {
      if (menuItem.route === this.activeRoute) {
        menuItem.active = true;
      } else {
        if (menuItem.active) {
          menuItem.active = false;
        }
      }
    }
}

But when the active property is changed, rerendering of the menu item does not happen.

🤔 Expected Behavior

I would expect for an active class to change on the menu item click

😯 Current Behavior

It does not trigger rendering of menuItems on active property change

🌍 Your Environment

  • OS & Device: Windows
  • Browser: Microsoft Edge
  • Version: 2.0.0-beta.26

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA bugcommunity:requestIssues specifically reported by a member of the community.status:needs-informationThis issue needs more information

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions