Skip to content

Commit

Permalink
fix(masthead): remove console errors (#4404)
Browse files Browse the repository at this point in the history
### Related Ticket(s)

#4403 

### Description

remove console errors from overflow navigation work

### Changelog

**New**

- checks if components exist before calling function

<!-- React and Web Component deploy previews are enabled by default. -->
<!-- To enable additional available deploy previews, apply the following -->
<!-- labels for the corresponding package: -->
<!-- *** "package: services": Services -->
<!-- *** "package: utilities": Utilities -->
<!-- *** "package: styles": Carbon Expressive -->
<!-- *** "RTL": React / Web Components (RTL) -->
<!-- *** "feature flag": React / Web Components (experimental) -->
  • Loading branch information
ariellalgilmore authored Nov 4, 2020
1 parent dbad74b commit 5756618
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/react/src/components/Masthead/HeaderNavContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ const HeaderNavContainer = ({ children }) => {
records => {
records.forEach(record => {
if (
contentLeftRef.current &&
record.target.classList.contains(
contentLeftRef.current.className
)
) {
caretLeftRef.current.hidden = record.isIntersecting;
}
if (
contentRightRef.current &&
record.target.classList.contains(
contentRightRef.current.className
)
Expand Down Expand Up @@ -152,18 +154,20 @@ const HeaderNavContainer = ({ children }) => {
if (event.shiftKey) {
//Focus previous input
if (
document.activeElement.parentElement.previousSibling &&
document.activeElement.parentElement.previousSibling.offsetLeft +
position <=
buttonSize
buttonSize
) {
paginateLeft();
}
} else {
//Focus next input
if (
document.activeElement.parentElement.nextSibling &&
document.activeElement.parentElement.nextSibling.offsetLeft +
document.activeElement.parentElement.nextSibling.offsetWidth >=
containerRef.current.offsetWidth - buttonSize
containerRef.current.offsetWidth - buttonSize
) {
paginateRight();
}
Expand Down

0 comments on commit 5756618

Please sign in to comment.