question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onCancel not being called for modals

See original GitHub issue

Environment(required)

  • antd version: 2.7.4
  • OS and its version: Windows 10
  • Browser and its version: chrome 56.0.2924.87

What did you do? Please provide steps to re-produce your problem.

    Modal.confirm({
      title: 'Sample title',
      content: `Sample content`,
      onCancel: () => console.log('cancelling') });

What do you expected?

a console log when pressing ESC key

What happens?

The modal closes but the log is not printed

Re-producible online demo

http://codepen.io/elios264/pen/RpoVeE

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
NE-SmallTowncommented, Mar 8, 2017

Hi elios.I think it’s not a bug,because the doc say that onCancel don’t care about esc,it just handle cancel button and x button.And I think maybe it’s brower’s behavior(i.e.,remove all nodes which are masks ),you can use alert() or confirm() on the browser console and then press “Esc” key,you will see that they will disappear.

Maybe these help?

Five unexpected uses for the Esc key

bootstrap modal handle esc

bootstrap modal doc

relevant issue1

relevant issue2

relevant issue3

Chrome keyboard shortcuts

0reactions
lock[bot]commented, May 1, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap close modal not working - Stack Overflow
The first is the close icon and the other one is cancel button, both use data-dismiss to close the modal. However, both of...
Read more >
Cancel on modal confirmation dialog not working
Override the PreSaveAction in order to cancel the save. function PreSaveAction() { if (confirm("Confirmez-vous ce choix de réforme ?
Read more >
Modal - Ant Design
Asynchronously close a modal dialog when the OK button is pressed. ... Let onCancel/onOk function return a promise object to delay closing the...
Read more >
Cancel a React Modal with Escape Key or External Click
The useEffect automatically calls our returned cleanup function when the useEffect dismounts. Thanks! We're not quite there yet, though. We need ...
Read more >
Modals manager | Mantine
children – additional modal content displayed before actions; onCancel – called when cancel button is clicked; onConfirm – called when confirm button is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found