Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

feat(uib-tabset.active): Support name/object ability to set active #5703

Closed
troywoy opened this issue Mar 28, 2016 · 3 comments
Closed

feat(uib-tabset.active): Support name/object ability to set active #5703

troywoy opened this issue Mar 28, 2016 · 3 comments

Comments

@troywoy
Copy link

troywoy commented Mar 28, 2016

We just updated from [email protected] to [email protected] which moves active from each uib-tab to the containing uib-tabset. While this simplifies the amount of tags/code/etc, the only way to set an active tab is via index value. Indices are very error prone and typically a nightmare to manage, especially when adding or removing tabs as development and/or client requirements change.

How our team used active in [email protected] was along the lines of:

<div uib-tabset>
  <div uib-tab heading="Foobar" active="foobarActive">...</div>
  <div uib-tab heading="ABC" active="abcActive">...</div>
</div>

Then in our JavaScript, we were able to simply do $scope.foobarActive = true; which set Foobar visible. This meant no matter the order of the tabs, addition of new tabs, or removal of unwanted tabs the JavaScript wouldn't have the potential of breaking as easily as an indice change.

In [email protected], we clearly have to use an index (being 0 or 1 for the previous example). However, we'd like to request the ability to set via a name (or maybe object pointer???), such as:

<div uib-tabset active="activeTab">
  <div uib-tab heading="Foobar">...</div>
  <div uib-tab heading="ABC">...</div>
</div>

Then in our JavaScript, something like $scope.activeTab = 'Foobar'; (or some kind of unique key) would set Foobar visible. With this example if we put tab 123 in between Foobar and ABC, then all references to ABC expecting it to be at index 1 would now be broken.

Angular: 1.5
UIBS: 1.2.5
Bootstrap: 3.3.6

@icfantv
Copy link
Contributor

icfantv commented Mar 28, 2016

@twh1808, while we appreciate the thorough write up, please be respectful of our time by extending us the courtesy of searching existing issues as this is a duplicate of #5687 and corresponding PR #5577 (which is still waiting a response from the original submitter).

@troywoy
Copy link
Author

troywoy commented Mar 28, 2016

@icfantv, I did review the PRs and Issues and I did take note of the ones you're referencing. However, based on the confusing name of index (since I believe most expect that to be an 0-based integer) and the minimal details it appeared as that was attempting to fix things like activeTab = '1' where the typeof activeTab === 'string' and not actually a number.

I see now after digging deeper into the source that index is really "any old value" so this does become a duplicate.

@icfantv
Copy link
Contributor

icfantv commented Mar 28, 2016

I agree that if we allow strings, then the term index is not great.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants