notiflix / Notiflix

Notiflix is a pure JavaScript library for client-side non-blocking notifications, popup boxes, loading indicators, and more that makes your web projects much better.
https://notiflix.github.io
MIT License
647 stars 55 forks source link

[BUG] - call confirm after prompt #60

Closed injaan closed 2 years ago

injaan commented 2 years ago

Describe the bug

I called confirm window after successful prompt action but confirm not called, nothing happened

To Reproduce

call confirm after prompt

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

Add any other context about the problem here.

furcan commented 2 years ago

Hi @injaan

Can you please share your snippet to see what is happening?


In addition: You need to be sure that the previous Confirm method should be removed(there is a CSS animation delay(of 300 milliseconds), so it is not removed immediately) from DOM.

The Confirm module is allowing to show only one confirmation at the same time. This means you will not get the second one if you are calling the second one before the previous one is completely removed.

injaan commented 2 years ago

Hi @furcan thank you for answered for my problem I tried following

Confirm.prompt(
    'Are you sure',
    'Please enter number!',
    '10',
    'Continue',
    'Cancel',
    (value) => {
        if(value){
            Confirm.show(
                'Confirm',
                `Your chosen number is ${value} are you sure to continue?`,
                'Yes',
                'No',
                () => {
                  console.log("confirmed", value);
                }
              );
        }
    }
);

So is it really not possible to call 'Confirm' right after 'Prompt'? I think call confirm after prompt would be really useful if it is implemented.

furcan commented 2 years ago

Hi @injaan

This is your solution.

Thanks.

var delay = 300; // the default value

Confirm.prompt(
  "Are you sure",
  "Please enter number!",
  "10",
  "Continue",
  "Cancel",
  (value) => {
    if (value) {
      var wait = setTimeout(function () {
        Confirm.show(
          "Confirm",
          `Your chosen number is ${value} are you sure to continue?`,
          "Yes",
          "No",
          () => {
            console.log("confirmed", value);
          }
        );
        clearTimeout(wait);
      }, delay + 1);
    }
  },
  undefined,
  {
    cssAnimationDuration: delay,
  },
);
injaan commented 2 years ago

@furcan thank you

furcan commented 2 years ago

You are welcome 🙏