fix(modal): disable backdrop even if actions missing (#532)

This commit is contained in:
witt
2021-05-03 15:21:55 +08:00
committed by GitHub
parent 019d2a5182
commit aabb689337
2 changed files with 4 additions and 4 deletions

View File

@@ -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}>
@@ -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', () => {

View File

@@ -66,7 +66,7 @@ const Modal: React.FC<React.PropsWithChildren<ModalProps>> = ({
}, [open])
const closeFromBackdrop = () => {
if (disableBackdropClick && hasActions) return
if (disableBackdropClick) return
closeModal()
}