Skip to content

The notification component clicks the close icon and calls the onClose function repeatedly #6144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
Dai-ww opened this issue Dec 7, 2022 · 6 comments · Fixed by #6150
Closed
1 task
Labels

Comments

@Dai-ww
Copy link

Dai-ww commented Dec 7, 2022

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.2.14

Environment

node 16.15.1 macOS Ventura13.0 vue3.2.31

Reproduction link

Edit on CodeSandbox

Steps to reproduce

1、点击notification box
2、点击关闭图标观察控制台 等待几秒后再次观察控制台

What is expected?

点击关闭图标调用close函数 不点击则定时器触发close函数

What is actually happening?

重复调用close函数

@kovsu
Copy link
Member

kovsu commented Dec 8, 2022

因为 Notificaiton,设置了自动关闭,有个定时器。你应该在这里面设置 duration 为 0,这样就不会出现调用两次 onClose 的情况了。

notification.open({
    .....
    duration: 0,
});

@Dai-ww
Copy link
Author

Dai-ww commented Dec 8, 2022

这是自动关闭的时间,但是如果我手动点击了关闭图标。按理说定时器应该不会触发。

因为 Notificaiton,设置了自动关闭,有个定时器。你应该在这里面设置 duration 为 0,这样就不会出现调用两次 onClose 的情况了。

notification.open({
    .....
    duration: 0,
});

@kovsu
Copy link
Member

kovsu commented Dec 8, 2022

image
事实上他就是触发了两次 onClose 事件,一次你手动关闭,第二次就是这个 自动关闭 事件。而且上面这个图片,他也说了如果要取消自动关闭就将 duration 赋值为 0。

@Dai-ww
Copy link
Author

Dai-ww commented Dec 9, 2022

  1. 当前设计是否为antd expected behavior?
  2. 如果设置0,会导致用户体验发生改变。由原本用户需“指定时间”或者“手动”关闭通知变更为只能手动关闭。
  3. 当前表现与antd-react行为表现是否一致?
    react 官方表现如下
    https://codesandbox.io/s/zi-dong-guan-bi-de-yan-shi-antd-5-0-4-forked-vrkqq6?file=/demo.tsx

@kovsu
Copy link
Member

kovsu commented Dec 10, 2022

  1. 当前设计是否为antd expected behavior?
  2. 如果设置0,会导致用户体验发生改变。由原本用户需“指定时间”或者“手动”关闭通知变更为只能手动关闭。
  3. 当前表现与antd-react行为表现是否一致?
    react 官方表现如下
    https://codesandbox.io/s/zi-dong-guan-bi-de-yan-shi-antd-5-0-4-forked-vrkqq6?file=/demo.tsx

今天,看了下源码。发现就是,他给这个添加了 mouseLeavemouseEnter 事件。在 unMounted 之后,他还运行了一次 mouseLeave 事件,又创建了一次定时器,所以导致 onClose 事件触发了两次。

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants