Skip to content

Commit

Permalink
Merge pull request uswds#2386 from uswds/bh-footer-fix
Browse files Browse the repository at this point in the history
Disable hiding footer menus on desktop
  • Loading branch information
Maya Benari authored Mar 13, 2018
2 parents 88531da 896d633 commit da9624c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
25 changes: 17 additions & 8 deletions spec/unit/footer/footer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 83,25 @@ describe('big footer accordion', function () {
assertHidden(lists[ 0 ], false);
});

it('closes other panels', function () {
it('closes other panels on small screens', function () {
return resizeTo(400)
.then(() => {
buttons[ 0 ].click();
assertHidden(lists[ 0 ], false);
assertHidden(lists[ 1 ], true);
assertHidden(lists[ 2 ], true);

buttons[ 1 ].click();
assertHidden(lists[ 0 ], true);
assertHidden(lists[ 1 ], false);
assertHidden(lists[ 2 ], true);
});
});

it('does not close other panels on larger screens', function () {
buttons[ 0 ].click();
assertHidden(lists[ 0 ], false);
assertHidden(lists[ 1 ], true);
assertHidden(lists[ 2 ], true);

buttons[ 1 ].click();
assertHidden(lists[ 0 ], true);
assertHidden(lists[ 1 ], false);
assertHidden(lists[ 2 ], true);
assertHidden(lists[ 2 ], false);
});

});
28 changes: 15 additions & 13 deletions src/js/components/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 18,21 @@ const HIDE_MAX_WIDTH = 600;
const DEBOUNCE_RATE = 180;

const showPanel = function () {
const list = this.closest(LIST);
list.classList.remove(HIDDEN);

// NB: this *should* always succeed because the button
// selector is scoped to ".{prefix}-footer-big nav"
const lists = list.closest(NAV)
.querySelectorAll('ul');

forEach(lists, el => {
if (el !== list) {
el.classList.add(HIDDEN);
}
});
if (window.innerWidth < HIDE_MAX_WIDTH) {
const list = this.closest(LIST);
list.classList.remove(HIDDEN);

// NB: this *should* always succeed because the button
// selector is scoped to ".{prefix}-footer-big nav"
const lists = list.closest(NAV)
.querySelectorAll('ul');

forEach(lists, el => {
if (el !== list) {
el.classList.add(HIDDEN);
}
});
}
};

const resize = debounce(() => {
Expand Down
4 changes: 4 additions & 0 deletions src/stylesheets/components/_footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 18,10 @@

&:hover {
text-decoration: underline;

@include media($medium-screen) {
text-decoration: none;
}
}
}

Expand Down

0 comments on commit da9624c

Please sign in to comment.