Skip to content

Commit

Permalink
fix(modal): disable backdrop even if actions missing
Browse files Browse the repository at this point in the history
  • Loading branch information
unix committed May 3, 2021
1 parent 019d2a5 commit 9014ff6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions components/modal/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Modal', () => {
expect(closeHandler).not.toHaveBeenCalled()
})

it('should ignore backdrop disabled when actions missing', async () => {
it('should disable backdrop even if actions missing', async () => {
const closeHandler = jest.fn()
const wrapper = mount(
<Modal open={true} disableBackdropClick onClose={closeHandler}>
Expand All @@ -72,8 +72,8 @@ describe('Modal', () => {
)
wrapper.find('.backdrop').simulate('click', nativeEvent)
await updateWrapper(wrapper, 500)
expectModalIsClosed(wrapper)
expect(closeHandler).toHaveBeenCalled()
expectModalIsOpened(wrapper)
expect(closeHandler).not.toHaveBeenCalled()
})

it('should ignore event when action disabled', () => {
Expand Down
2 changes: 1 addition & 1 deletion components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const Modal: React.FC<React.PropsWithChildren<ModalProps>> = ({
}, [open])

const closeFromBackdrop = () => {
if (disableBackdropClick && hasActions) return
if (disableBackdropClick) return
closeModal()
}

Expand Down

0 comments on commit 9014ff6

Please sign in to comment.