mirror of
https://github.com/zhigang1992/react.git
synced 2026-03-27 22:54:38 +08:00
fix(modal): disable backdrop even if actions missing (#532)
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
@@ -66,7 +66,7 @@ const Modal: React.FC<React.PropsWithChildren<ModalProps>> = ({
|
||||
}, [open])
|
||||
|
||||
const closeFromBackdrop = () => {
|
||||
if (disableBackdropClick && hasActions) return
|
||||
if (disableBackdropClick) return
|
||||
closeModal()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user