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

ConfirmPopup: Target not set properly after await/promise #5706

Open
mnaeemshakir opened this issue May 8, 2024 · 3 comments
Open

ConfirmPopup: Target not set properly after await/promise #5706

mnaeemshakir opened this issue May 8, 2024 · 3 comments
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@mnaeemshakir
Copy link

Describe the bug

Steps to reproduce are simple

1 - Copy an example from https://primevue.org/confirmpopup/
2 - Make an API call before showing/triggering confirm
3 - Confirm popup will be displayed on upper left corner of the screen.

Reproducer

https://stackblitz.com/edit/bycjcy-g8skn4?file=src%2FApp.vue

PrimeVue version

3.5

Vue version

3.x

Language

TypeScript

Build / Runtime

Vue CLI App

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@mnaeemshakir mnaeemshakir added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label May 8, 2024
@ichenhe
Copy link

ichenhe commented Jun 8, 2024

May be the same problem: the popup is moved to the left-top corner if the stopPropagation is called. Even though stop the event after calling confirm.require().

@cmcnicholas
Copy link

Same issue.

image

Results in:

image

Removing the awaited code before show works.

@Rubikoid
Copy link

Rubikoid commented Dec 27, 2024

Looks like ConfirmPopup expecting prepogated click event from button to realign itself properly: https://github.com/primefaces/primevue/blob/master/packages/primevue/src/confirmpopup/ConfirmPopup.vue#L232

I'm came to totally cursed solution:

const popupRef = useTemplateRef("popup");
function show(event) {
    confirm.require({
        onShow: () => {
            setTimeout(() => {
                popupRef.value.alignOverlay()
            }, 0.1);
        }
    });
}
<ConfirmPopup ref="popup" />

setTimeout here required due to onShow calling happens before popupRef.container getting filled, so overwise it will crash.
I can't imagine any better solutions than 0.1 timeout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

4 participants