(p => {
{props.closeable && (
{
+ onClick={e => {
setVisible(false)
- props.onClose?.()
+ props.onClose?.(e)
}}
>
diff --git a/src/components/notice-bar/tests/notice-bar.test.tsx b/src/components/notice-bar/tests/notice-bar.test.tsx
index 66490b704a..980e842518 100644
--- a/src/components/notice-bar/tests/notice-bar.test.tsx
+++ b/src/components/notice-bar/tests/notice-bar.test.tsx
@@ -23,10 +23,20 @@ describe('NoticeBar', () => {
expect(renderer2.getByTestId('alert')).toHaveClass(`${classPrefix}-alert`)
})
- test('can be close', async () => {
- const fn = jest.fn()
+ test('can be close and not propagate', async () => {
+ const onClose = jest.fn()
+ const onClick = jest.fn()
const { getByTestId } = render(
-
+ {
+ e.stopPropagation()
+ onClose()
+ }}
+ onClick={onClick}
+ />
)
const el = getByTestId('notice')
@@ -35,7 +45,8 @@ describe('NoticeBar', () => {
fireEvent.click(iconEl)
expect(el).not.toBeInTheDocument()
- expect(fn).toBeCalled()
+ expect(onClose).toBeCalled()
+ expect(onClick).not.toBeCalled()
})
test('`icon` prop', async () => {