Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Critical bugs masthead nav #764

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/spark-core/components/_wide-navigation.scss
Expand Up @@ -43,10 +43,12 @@
font-weight: bold;
}

.sprk-c-WideNavigation__item.sprk-u-FocusWithin:not(.sprk-c-WideNavigation__item--sub) > .sprk-c-WideNavigation__link,
.sprk-c-WideNavigation__item:focus-within:not(.sprk-c-WideNavigation__item--sub) > .sprk-c-WideNavigation__link,
.sprk-c-WideNavigation__item--open > .sprk-c-WideNavigation__link,
.sprk-c-WideNavigation__item--active > .sprk-c-WideNavigation__link {
&::after {
background-color: $red;
background-color: $black;
content: ' ';
height: 3px;
display: block;
Expand All @@ -68,7 +70,7 @@
&:active,
&:focus,
&:hover {
@include HoverLine($color: $red, $width: 85%);
@include HoverLine($color: $black, $width: 85%);
}
}

Expand Down Expand Up @@ -98,7 +100,7 @@
}

.sprk-c-WideNavigation__arrow {
fill: $red;
fill: $black;
width: $icon-m;
margin: -3px $space-s 0 $space-s; // negative margin to visually align the arrow
}
2 changes: 2 additions & 0 deletions packages/spark-core/components/tabs.js
Expand Up @@ -94,8 +94,10 @@ const bindUIEvents = (element) => {
event.preventDefault();
tabpanels[getActiveTabIndex(tabs)].focus();
} else if (event.keyCode === keys.home) {
resetTabs(tabs, tabpanels);
setActiveTab(tabs[0], tabpanels[0]);
} else if (event.keyCode === keys.end) {
resetTabs(tabs, tabpanels);
setActiveTab(tabs[tabs.length - 1], tabpanels[tabpanels.length - 1]);
}
});
Expand Down
4 changes: 0 additions & 4 deletions packages/spark-core/components/wide-navigation.js
Expand Up @@ -24,10 +24,6 @@ const bindUIEvents = (element) => {

element.addEventListener('focusin', (e) => {
e.stopPropagation();
if (e.target.parentNode.classList.contains('sprk-c-WideNavigation__item')
&& !e.target.parentNode.classList.contains('sprk-c-WideNavigation__item--sub')) {
e.target.parentNode.classList.add('sprk-c-WideNavigation__item--open');
}
hideAllDropDowns(subNavContainers, expandableListItems);
showDropDown(element);
});
Expand Down
1 change: 1 addition & 0 deletions packages/spark-core/spark-core.js
Expand Up @@ -25,6 +25,7 @@ import './utilities/polyfills/StringIncludes';
import './utilities/polyfills/ArrayFind';
import './utilities/polyfills/NodeListForEach';
import './utilities/polyfills/classListSVG';
import './utilities/polyfills/focusWithin';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yodasw16 @afebbraro Do you guys think its worth it to load a polyfill for this?
If I dont, then in IE / Edge, when a user tabs into a wide-nav item's submenu, the wide-nav item wont be marked active. Mouse use is fine, this would only affect keyboard only.

Copy link
Contributor

@yodasw16 yodasw16 Nov 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They will still be able to see which submenu item they are currently on? If so, the submenu being visually under the main item should be enough to indicate which one is active. Unless I'm misunderstanding.

On the other hand, the polyfill is tiny (< 1k).


const SparkCore = ({ datePickerConfig = {} } = {}) => {
requiredSelect();
Expand Down
34 changes: 34 additions & 0 deletions packages/spark-core/utilities/polyfills/focusWithin.js
@@ -0,0 +1,34 @@
/* eslint-disable */
(function(window, document){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we convert this to ES6 to match the rest of our JS?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ended up removing the polyfill

'use strict';
var slice = [].slice;
var removeClass = function(elem){
elem.classList.remove('sprk-u-FocusWithin');
};
var update = (function(){
var running, last;
var action = function(){
var element = document.activeElement;
running = false;
if(last !== element){
last = element;
slice.call(document.getElementsByClassName('sprk-u-FocusWithin')).forEach(removeClass);
while(element && element.classList){
element.classList.add('sprk-u-FocusWithin');
element = element.parentNode;
}
}
};
return function(){
if(!running){
requestAnimationFrame(action);
running = true;
}
};
})();
document.addEventListener('focus', update, true);
document.addEventListener('blur', update, true);
update();
})(window, document);
/* eslint-enable */