diff --git a/showcase/app/components/mock/app/sidebar/app-side-nav.gts b/showcase/app/components/mock/app/sidebar/app-side-nav.gts index e1c3d577968..6f55aa824ba 100644 --- a/showcase/app/components/mock/app/sidebar/app-side-nav.gts +++ b/showcase/app/components/mock/app/sidebar/app-side-nav.gts @@ -24,6 +24,7 @@ export interface MockAppSidebarAppSideNavSignature { isResponsive?: HdsAppSideNavSignature['Args']['isResponsive']; isCollapsible?: HdsAppSideNavSignature['Args']['isCollapsible']; showDevToggle?: boolean; + onToggleMinimizedStatus?: HdsAppSideNavSignature['Args']['onToggleMinimizedStatus']; }; Element: HdsAppSideNavSignature['Element']; } @@ -47,6 +48,7 @@ export default class MockAppSidebarAppSideNav extends Component { + if (isOpen) this.isRendered = false; + }; + + +} diff --git a/showcase/app/templates/page-components/app-side-nav/index.hbs b/showcase/app/templates/page-components/app-side-nav/index.hbs index 81d120f561f..e70b796af9e 100644 --- a/showcase/app/templates/page-components/app-side-nav/index.hbs +++ b/showcase/app/templates/page-components/app-side-nav/index.hbs @@ -699,4 +699,22 @@ @label="Full AppFrame with AppHeader & AppSideNav (small viewport)" /> + + + + + This demo verifies that when the `AppSideNav` component is removed from the DOM while page overflow styles are + overridden, the page's scroll functionality is properly restored. + + + + To check this, expand and then collapse the AppSideNav. Then try to scroll the page. + + \ No newline at end of file diff --git a/showcase/tests/integration/components/hds/app-side-nav/index-test.js b/showcase/tests/integration/components/hds/app-side-nav/index-test.js index 77c2ee1959a..23ca9d9f657 100644 --- a/showcase/tests/integration/components/hds/app-side-nav/index-test.js +++ b/showcase/tests/integration/components/hds/app-side-nav/index-test.js @@ -314,13 +314,49 @@ module('Integration | Component | hds/app-side-nav/index', function (hooks) { assert.dom('body', document).doesNotHaveStyle('overflow'); }); + test('when expanded in mobile and the component is removed from the DOM, scrolling is enabled', async function (assert) { + this.mockMedia(); + + let calls = []; + this.setProperties({ + onDesktopViewportChange: (...args) => calls.push(args), + }); + + this.set('isAppSideNavRendered', true); + + await render(hbs`{{#if this.isAppSideNavRendered}} + +{{/if}}`); + + await this.changeBrowserSize(false); + + assert.deepEqual( + calls[1], + [false], + 'resizing to mobile triggers a false event', + ); + + await click('.hds-app-side-nav__toggle-button'); + + assert.dom('body', document).hasStyle({ + overflow: 'hidden', + }); + + this.set('isAppSideNavRendered', false); + + assert.dom('body', document).doesNotHaveStyle('overflow'); + }); + test('when collapsed, the content in the AppSideNav is not focusable', async function (assert) { await render(hbs` - -`); + +`); await click('.hds-app-side-nav__toggle-button'); assert.dom('#test-app-side-nav').hasClass('hds-app-side-nav--is-minimized');