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

Fix #11824: AjaxStatus always hide in oncomplete #11825

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

melloware
Copy link
Member

@melloware melloware commented Apr 26, 2024

Fix #11824: AjaxStatus always hide in oncomplete

This answers the question asked previously...

Could anyone explain this to me?

if (event !== 'complete' || this.jq.children().filter(this.toFacetId('complete')).length) {
            this.jq.children().hide().filter(this.toFacetId(event)).show();
        }

Basically upon oncomplete we must call facets.hide() because we are done.

cc @stolp

The code is easier to read below than in the change:

    trigger: function(event, args) {
        var callback = this.cfg[event];
        if (callback) {
            callback.apply(document, args);
        }

        // Get the facet based on the event
        var facets = this.jq.children();
        var facet = facets.filter(this.toFacetId(event));

        // We have the following events:
        // 1) start
        // 2) success or error
        // 3) complete
        switch (event) {
            case 'start':
                // always hide other facets on start
                facets.hide();
                
                if (facet.length > 0) {
                    facet.show();
                }
                break;

            case 'success':
            case 'error':
                // we now expect that either a complete or success/error facet is defined
                // if no success/error is defined, lets just rely upon the complete-facet
                if (facet.length > 0) {
                    facets.hide();
                    facet.show();
                }
                break;

            case 'complete':
                var pfArgs = args[2];
                // if the current request leads in a redirect, skip hiding the previous facet (in best case this is the start-facet)
                // when a sucess/error-facet is defined, this wont work as expected as the 'redirect' information is not available before
                if (!pfArgs || pfArgs.redirect) {
                    return;
                }
                
                // #11824 we must hide all facets and show either complete or default
                facets.hide();

                // Show complete-facet if defined, else show default facet
                if (facet.length > 0) {
                    facet.show();
                }
                break;
        }
    }

the only important change is moving the hide in the complete

               // #11824 we must hide all facets and show either complete or default
               facets.hide();

@melloware melloware added the 🐞 defect Bug...Something isn't working label Apr 26, 2024
@tandraschko
Copy link
Member

we really need to some tests now
i fear breaking all the other cases now

@melloware
Copy link
Member Author

I will add some tests.

@melloware
Copy link
Member Author

@tandraschko added a battery of Integration tests that HELPED ME FIND A BUG!

  • tests all facets including similuting an error facet since that is hard to do
  • a specific test for this actual use case from @stolp

@melloware melloware force-pushed the PF11824 branch 2 times, most recently from 4e9fff4 to cdd4cba Compare April 26, 2024 17:21
@tandraschko
Copy link
Member

if you tested the linked issues and they work -> +1

@melloware melloware merged commit 3722511 into primefaces:master Apr 29, 2024
12 checks passed
@melloware melloware deleted the PF11824 branch April 29, 2024 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 defect Bug...Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AjaxStatus: Not returning to default when located outside the ajax partial submit update scope
2 participants