NG-ZORRO / ng-zorro-antd

Angular UI Component Library based on Ant Design
https://ng.ant.design
MIT License
8.86k stars 3.91k forks source link

nz-modal 不响应键盘事件和点击蒙层关闭 #6424

Closed MzoroHaHa closed 3 years ago

MzoroHaHa commented 3 years ago

Reproduction link

https://wu31fx--run.stackblitz.io?stackbitz上不能重现的

Steps to reproduce

  1. ng new project-name
  2. ng add ng-zorro-antd
  3. 将app.component.html改为 如下
    <nz-modal
    [(nzVisible)]="s"
    nzTitle="The first Modal"
    [nzContent]="'ss'"
    [nzKeyboard]="true"
    (nzOnOk)="s=false"
    [nzMaskClosable]="true"
    >
    </nz-modal>
    <button (click)="s = true">test</button>

    s 变量在组件中已经添加了,且不是private

  4. 启动程序,打开浏览器可以出现, 点蒙层,按esc, 点关闭按键都不会关闭
  5. package.json如下
  "dependencies": {
    "@angular/animations": "~11.0.5",
    "@angular/common": "~11.0.5",
    "@angular/compiler": "~11.0.5",
    "@angular/core": "~11.0.5",
    "@angular/forms": "~11.0.5",
    "@angular/platform-browser": "~11.0.5",
    "@angular/platform-browser-dynamic": "~11.0.5",
    "@angular/router": "~11.0.5",
    "ng-zorro-antd": "^11.1.0",
    "rxjs": "~6.6.0",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.1100.5",
    "@angular/cli": "~11.0.5",
    "@angular/compiler-cli": "~11.0.5",
    "@types/jasmine": "~3.6.0",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "~5.1.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "^1.5.0",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~4.0.2"
  }

What is expected?

响应esc ,点蒙层关闭,点关闭按钮关闭

What is actually happening?

如题 除非自己代码实现 另 Service 方式打开的modal 是正常的

Environment Info
ng-zorro-antd 11.1.0
Browser chrome 版本 88.0.4324.150(正式版本) (64 位)

过年好

zorro-bot[bot] commented 3 years ago

Translation of this issue:

NZ-MODAL does not respond to keyboard events and click Mongolia to close

reproduction link

[https://wu31fx--run.stackblitz.iO?stackBitz can't be reproduced on https://wu311fx--run.stackBlitz.io?stackBitz can not be reproduced)

steps to reproduce

  1. NG New Project-Name
  2. Ng Add ng-zorro-ANTD
  3. Change App.Component.html as follows ` <nz-modal [(nzvisible)] = "s" nztitle = "the first modal" [NZCONTENT] = "'ss'" [NZKEYBOARD] = "True" (nzonok) = "s = false" [nzmaskclosable] = "True"

    </ nz-modal>

  4. Start the program, open the browser, can appear, point, press ESC, point close the button will not close
  5. Package.json as follows

` "dependencies": { "@ Angular / Animation": "~ 11.0.5", "@ Angular / Common": "~ 11.0.5", "@ Angular / Compiler": "~ 11.0.5", "@ Angular / Core": "~ 11.0.5", "@ Angular / Forms": "~ 11.0.5", "@ Angular / Platform-Browser": "~ 11.0.5", "@ Angular / Platform-Browser-Dynamic": "~ 11.0.5", "@ Angular / Router": "~ 11.0.5", "Ng-Zorro-ANTD": "^ 11.1.0", "RXJS": "~ 6.6.0", "TSLIB": "^ 2.0.0", "zone.js": "~ 0.10.2" } "devdependencies": { "@ angular-devkit / build-angular": "~ 0.1100.5", "@ Angular / CLI": "~ 11.0.5", "@ Angular / Compiler-CLI": "~ 11.0.5", "@ Types / Jasmine": "~ 3.6.0", "@ Types / Node": "^ 12.11.1", "Codelyzer": "^ 6.0.0", "Jasmine-Core": "~ 3.6.0", "Jasmine-Spec-Reporter": "~ 5.0.0", "Karma": "~ 5.1.0", "Karma-Chrome-Launcher": "~ 3.1.0", "Karma-coverage": "~ 2.0.3", "Karma-Jasmine": "~ 4.0.0", "Karma-jasmine-html-reporter": "^ 1.5.0", "Protractor": "~ 7.0.0", "TS-NODE": "~ 8.3.0", "TSLINT": "~ 6.1.0", "TypeScript": "~ 4.0.2" } `

What is expected?

Respond to the ESC, the point is closed, click the button to close the button

What is actually happens?

Question Unless your code is implemented Another service mode opened Modal is normal

ENVIRONMENT INFO
Ng-Zorro-ANTD 11.1.0
Browser Chrome version 88.0.4324.150 (official version) (64-bit)

happy New Year

vthinkxie commented 3 years ago

stackblitz与本地环境100%相同,在stackblitz上无法重现的代码,在我们电脑上同样无法重现

MzoroHaHa commented 3 years ago

这个道理我懂,我的电脑环境也没有不同,但是在我的本地环境确实发生了这个现象,如果有时间烦请尝试一次,没有出现就关闭吧。我觉得也挺奇怪的。