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.

promise return false in Modal component can't stop [button ok] loading

See original GitHub issue

Version

7.0.0-rc.1

Environment

any

Reproduction link

https://stackblitz.com/edit/angular-efvfiu?file=src/app/app.component.ts

Steps to reproduce

 this.confirmModal = this.modal.confirm({
      nzTitle: 'Do you Want to delete these items?',
      nzContent: 'When clicked the OK button, this dialog will be closed after 1 second',
      nzOnOk: () => new Promise((resolve, reject) => {
        // setTimeout(Math.random() > 0.5 ? resolve : reject, 1000);
         setTimeout(() => {
           return false;
         }, 1000);
      }).catch(() => console.log('Oops errors!'))
    });

What is expected?

when I return false, the [loading status] in OK button should be removed and back to normal status

What is actually happening?

always loading

Other?

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
cipchkcommented, Dec 17, 2018

resolve(false)

0reactions
ChenMatsucommented, Nov 5, 2021

用一個state控制visible 用promise控制按鈕狀態

 const [isVisible, setIsVisible] = useState(false);
 Modal.confirm({
      title: 'Do you Want to delete these items?',
      content: 'When clicked the OK button, this dialog will be closed after 1 second',
      visible: isVisible,
      onOk: () => {
        new Promise((resolve, reject) => {
          if(true) { 
             setIsVisible(false);
             return resolve(true);
          } else {
             return reject(false);
        })
      });
 
      
Read more comments on GitHub >

github_iconTop Results From Across the Web

how to resolve a function only when model window return ...
In first function I want blocked model window on which it will return me a promise and on that promise I will resolve...
Read more >
Implementing Modal Dialog Functions With Promise-based ...
Learn how to implement modal dialog functions with promise-based dialog results in your Angular application. See more from Wijmo today.
Read more >
Modal
Let onCancel/onOk function return a promise object to delay closing the dialog. In the various types of information modal dialog, only one button...
Read more >
How to Display the Progress of Promises in JavaScript
The video version of this tutorial can be found here... Our desired output will look something like this, as the tasks are in...
Read more >
How to correctly use preventDefault(), stopPropagation ...
In vanilla JavaScript, returning false doesn't have any effect on the default behaviour or event propagation of the element, as we can see...
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