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

ConfirmDialog displays stale data -> dialog is not reusable #958

Closed
linkvt opened this issue Sep 25, 2016 · 0 comments
Closed

ConfirmDialog displays stale data -> dialog is not reusable #958

linkvt opened this issue Sep 25, 2016 · 0 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@linkvt
Copy link

linkvt commented Sep 25, 2016

Hi,

I have a view where there is a list on the left side and the view of the selected item on the right side. The view on the right side has a delete button that uses the bound data of the list.
There is a <p-confirmDialog></p-confirmDialog> element in this view to confirm the deletion.

When calling confirm of the ConfirmationService several times, the dialog still shows the data (header, icon, message) of the first confirm call.

The problem lies here: confirmdialog.ts#L100
After the first confirm call (or already when defining the p-confirmDialog element with attributes) the fields message, icon and header are filled.
This means that ALL subsequent calls will have no effect on these fields, since they are already set.

IMO it should look somehow like this. The dialog fields are only set if the confirmation fields are set - defaults are not overwritten:

    constructor(protected el: ElementRef, protected domHandler: DomHandler, 
            protected renderer: Renderer, private confirmationService: ConfirmationService) {
        this.subscription = confirmationService.requireConfirmation$.subscribe(confirmation => {
            this.confirmation = confirmation;
            this.message = this.confirmation.message == null ? this.confirmation.message : this.message;
            this.message = this.confirmation.icon == null ? this.confirmation.icon : this.icon;
            this.message = this.confirmation.header == null ? this.confirmation.header : this.header;

Another solution would be to store the values from the HTML attributes in separate variables to not reuse values of old confirm calls.

Would this kinda be the intended behaviour or is it intended, that the dialog element gets created for each confirmation?

Edit: The current behavior is not intended according a recent PrimeNg blog post:

Great thing is the ability to use the same dialog over and over by other actions on the same component.
http://blog.primefaces.org/?p=4113

@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Sep 27, 2016
@cagataycivici cagataycivici added this to the 1.0.0-beta.17 milestone Sep 27, 2016
@cagataycivici cagataycivici self-assigned this Sep 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

2 participants