lumapps / lumapps/lumX

activeTab.position() undefined when initializing empty tabs

Open
#511 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.