Skip to content

Commit

Permalink
fix(ld-sidenav): dispatch collapsed change event on collapsible change
Browse files Browse the repository at this point in the history
  • Loading branch information
borisdiakur committed Oct 9, 2022
1 parent e362efe commit b04ae18
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/liquid/components/ld-sidenav/ld-sidenav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export class LdSidenav {
updateFullyCollapsible() {
this.fullyCollapsible =
this.collapsible && (!this.narrow || !this.activeSubnavContainsIcons())
if (!this.collapsible) this.collapsed = false
}

@Listen('click', {
Expand Down
20 changes: 20 additions & 0 deletions src/liquid/components/ld-sidenav/test/ld-sidenav.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1908,4 +1908,24 @@ describe('ld-sidenav', () => {
)
}
})

it('dispatches collapsed change event on collapsible change', async () => {
const page = await newSpecPage({
components: sidenavComponents,
html: '<ld-sidenav collapsible collapsed />',
})
const handler = jest.fn()
window.addEventListener('ldSidenavCollapsedChange', handler)

const ldSidenav = page.body.querySelector('ld-sidenav')

expect(ldSidenav).toHaveClass('ld-sidenav--collapsible')
expect(handler).not.toHaveBeenCalled()

ldSidenav.removeAttribute('collapsible')
await page.waitForChanges()

expect(ldSidenav).not.toHaveClass('ld-sidenav--collapsible')
expect(handler).toHaveBeenCalled()
})
})

1 comment on commit b04ae18

@vercel
Copy link

@vercel vercel bot commented on b04ae18 Oct 9, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

liquid – ./

liquid-uxsd.vercel.app
liquid-oxygen.vercel.app
liquid-git-main-uxsd.vercel.app

Please sign in to comment.