Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Add data test active to active navigation item (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
PatoBeltran authored Nov 12, 2019
1 parent af2ff3a commit 4886ac1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 7.0.6
### Changed
- Added data-test-active to active navigation item

## 7.0.5
### Fixed
- Fixed height of navigation scrollable container
Expand Down
13 changes: 11 additions & 2 deletions lib/components/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,17 @@ export function Navigation({ isExpanded, onClick, attr, children, farBottomChild
const items = topNavItemsContainer.current.getElementsByClassName('global-nav-item');

if (items && items.length > 0) {
const activeItemIndex = Array.prototype.findIndex.call(items,
(i: HTMLDivElement) => i.className.includes('global-nav-item-active'));
let activeItemIndex = -1;
for (let i = 0; i < items.length; i++) {
const item = items[i];
// Only take the first active link as active and set everything else to not active
if (item.className.includes('global-nav-item-active') && activeItemIndex === -1) {
activeItemIndex = i;
item.setAttribute('data-active', 'true');
} else {
item.removeAttribute('data-active');
}
}

if (activeItemIndex > -1) {
selectedBorderRef.current.style.display = 'block';
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/azure-iot-ux-fluent-controls",
"version": "7.0.5",
"version": "7.0.6",
"description": "Azure IoT UX Fluent Controls",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down

0 comments on commit 4886ac1

Please sign in to comment.