diff --git a/packages/dnb-design-system-portal/src/shared/menu/MainMenu.js b/packages/dnb-design-system-portal/src/shared/menu/MainMenu.js index f5e969f65ea..a377736102c 100644 --- a/packages/dnb-design-system-portal/src/shared/menu/MainMenu.js +++ b/packages/dnb-design-system-portal/src/shared/menu/MainMenu.js @@ -156,6 +156,7 @@ const customBodyStyle = css` ` const toggleContent = css` /* hide content if shown as overlay menu */ + .dnb-skip-link, .sticky-menu, .content-wrapper { display: none !important; diff --git a/packages/dnb-ui-lib/src/shared/tools.js b/packages/dnb-ui-lib/src/shared/tools.js index 8ebb2e99ec2..a6029d1198d 100644 --- a/packages/dnb-ui-lib/src/shared/tools.js +++ b/packages/dnb-ui-lib/src/shared/tools.js @@ -17,14 +17,34 @@ export const applyPageFocus = (key = 'default') => { element = document.querySelector('.dnb-no-focus') } if (element instanceof HTMLElement) { - if (!element.hasAttribute('tabindex')) { - element.setAttribute('tabindex', '-1') - } if ( - element.classList && - !element.classList.contains('dnb-no-focus') + [ + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'p', + 'div', + 'main', + 'nav', + 'header', + 'footer', + 'aside', + 'section', + 'article' + ].includes(element.type) ) { - element.classList.add('dnb-no-focus') + if (!element.hasAttribute('tabindex')) { + element.setAttribute('tabindex', '-1') + } + if ( + element.classList && + !element.classList.contains('dnb-no-focus') + ) { + element.classList.add('dnb-no-focus') + } } element.focus({ preventScroll: true }) }