activeTab.position() undefined when initializing empty tabs
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1.9k
- Forks
- 265
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
i use lx-tab for danymic content categories, here is a simplified version of my code:
js:
$scope.tabs = [];
$scope.tabs = loadTabsFromUrl(); // dynamic json data for tabs, like: [ 'Tab 1', 'Tab 2', 'Tab 3' ]
html:
<lx-tabs>
<lx-tab ng-repeat="_tab in tabs" lx.label="{{ _tab }}">
... some more dynamic content ...
</lx-tas>
</lx-tabs>
This must have worked with some older version of lumx, i guess 1.3, but after recent update to 1.4 and then 1.5 i'm receiving an error "cannot read property 'left' of undefined" in lumx.js (4994), which is:
var indicatorLeft = activeTab.position().left;
Obviously there is no activeTab when there are no tabs at all, so activeTab.position() is undefined.
I have fixed this by adding ng-if="tabs.length > 0" to <lx-tabs>
kind regards,
Marat
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at lumx.js around line 4994, where activeTab.position().left is read, and reproduce the issue with an empty tabs array rendered through the shown lx-tabs and ng-repeat markup. Done means initializing with no tabs no longer raises the undefined-property error, while populated tabs continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100