aforemny/material-components-web-elm

Setting all tabs inactive leads to runtime error

Closed this issue · 2 comments

This looks like another unfortunate interaction with Elm's virtual dom. If a TabBar has an active Tab, but then is updated so that no tab is active (Tab.setActive False for all tabs), a stream of runtime errors appears in the console. (I think I have seen this make the page unresponsive.)

(If the initial state is all tabs inactive there is no error.)

Here is an Ellie.

And here is the error that appears in the console:

component.ts:102 Uncaught TypeError: Cannot read property 'activate' of undefined
at Object.activateTabAtIndex (component.ts:102)
at rl.activateTab (foundation.ts:106)
at HTMLElement.set (custom-element.js:54)
at _VirtualDom_applyFacts (index.js:2842)
at _VirtualDom_applyPatch (index.js:3719)
at _VirtualDom_applyPatchesHelp (index.js:3702)
at _VirtualDom_applyPatches (index.js:3693)
at index.js:3948
at updateIfNeeded (index.js:4017)

Thanks for reporting this. I will look into this next! :)

I think a tab bar should have precisely one active tab. This should circumvent the problem and this it is fixed in ccfdb31. Thanks you for reporting this!

If you happen to have a good ues-case for tab bars with all inactive tabs, please open another issue!