Skip to content
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

drawer 能否提供全局事件,如:closeAll #2965

Open
tirelyl opened this issue Feb 25, 2019 · 5 comments
Open

drawer 能否提供全局事件,如:closeAll #2965

tirelyl opened this issue Feb 25, 2019 · 5 comments

Comments

@tirelyl
Copy link
Contributor

@tirelyl tirelyl commented Feb 25, 2019

What problem does this feature solve?

当页面打开一个或多个drawer时,用户点其它菜单或点击浏览器后退按钮,这些已打开的drawer需要一次性全关闭掉

What does the proposed API look like?

希望提供一个closeAll事件,在根页面监听路由变化,可关闭所有drawer,如下代码

constructor(
        private router: Router,
        private drawerService: NzDrawerService
    ) {
        router.events.subscribe(event => {
            if (event instanceof NavigationStart) {
                this.drawerService.closeAll();
            }
        });
    }
@ng-zorro-bot
Copy link
Collaborator

@ng-zorro-bot ng-zorro-bot commented Feb 25, 2019

Translation of this issue:


drawer Can provide global events, such as: closeAll

What problem does this feature solve?

When the page opens one or more drawers, the user clicks on another menu or clicks the browser back button. These opened drawers need to be closed all at once.

What does the proposed API look like?

I hope to provide a closeAll event, listen for routing changes in the root page, you can close all drawers, as shown below

Constructor(
        Private router: Router,
        Private drawerService: NzDrawerService
    ) {
        Router.events.subscribe(event => {
            If (event instanceof NavigationStart) {
                this.drawerService.closeAll();
            }
        });
    }
@hsuanxyz hsuanxyz self-assigned this Feb 25, 2019
@tirelyl
Copy link
Contributor Author

@tirelyl tirelyl commented Feb 25, 2019

@hsuanxyz 您好,我还想问下,drawer能否提供像modal那样在nzOnCancel中提供阻止modal关闭的方法,因为在大部分填写表单的场景下,用户如果改变了表单内容,需要询问用户是否保存之后再关闭drawer
image

@vthinkxie
Copy link
Member

@vthinkxie vthinkxie commented Feb 25, 2019

@hsuanxyz Modal也应该提供同样的方法

@tirelyl tirelyl closed this Feb 25, 2019
@tirelyl tirelyl reopened this Feb 25, 2019
@qq232650413
Copy link

@qq232650413 qq232650413 commented Mar 27, 2019

closeAll

select 和 DatePicker 类似下拉的那个面板 如何关闭?求解...

@qq232650413
Copy link

@qq232650413 qq232650413 commented Mar 27, 2019

方法

modal 有closeAll()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.