winjs / angular-winjs

Project to smooth the AngularJS/WinJS interaction
Other
126 stars 46 forks source link

Add new win-pivot-item after removing all, throws exception and breaks first tab #79

Open sondreb opened 8 years ago

sondreb commented 8 years ago

I have a win-pivot-item binded to an array of items, it works fine to add/remove and navigate between the tabs, but if I remove all, there occurs an exception on the first add. After that exception, the first tab is in a "broken" state, not possible to navigate to it. Not only is the first tab broken, the content of the other tabs are not displayed. It is possible to click the headers, but nothing appears.

I have created a codepen to reproduce the issue, but codepen does not supply the JavaScript error that occurs, but the behavior can be tested here.

http://codepen.io/sondreb/pen/VvGNJK

Steps to reproduce:

  1. Open the codepen.
  2. Click the Remove Tab twice.
  3. Click the Add Tab multiple times.
  4. Observe that the content is not shown, and that the first tab is no longer select-able.

This is where the debugger kicks in:

image

Content of data.stack:

"TypeError: Cannot read property 'classList' of undefined
    at HeaderStateStatic.HeaderStateBase.setActiveHeader (http://localhost:7601/libs/lib.js:136105:30)
    at HeaderStateStatic.handleNavigation (http://localhost:7601/libs/lib.js:136198:18)
    at http://localhost:7601/libs/lib.js:135618:37
    at CompletePromise_ctor.CompletePromise_then [as then] (http://localhost:7601/libs/lib.js:75889:49)
    at Pivot._loadItem (http://localhost:7601/libs/lib.js:135607:73)
    at Pivot.Object.defineProperty.set [as selectedIndex] (http://localhost:7601/libs/lib.js:135431:30)
    at Pivot._handleItemInserted (http://localhost:7601/libs/lib.js:135736:36)
    at eventMixin.dispatchEvent (http://localhost:7601/libs/lib.js:74138:34)
    at _Base.Class.define._notifyItemInserted (http://localhost:7601/libs/lib.js:97550:30)
    at _Base.Class.derive.splice (http://localhost:7601/libs/lib.js:99489:34)"

(Posted duplicate of this bug to the WinJS repo, this is probably not a angular+winjs issue)