简体   繁体   中英

Is there a way to get [resetFilterOnHide]=“true” on p-dropdown to work with primeng 5.2.7?

The [resetFilterOnHide]="true" on p-dropdown does not work. If I type in the filter bar, click outside of the dropdown to close it, and then enter the dropdown again, the filter I entered is still there.

I am using primeng 5.2.7 in an angular 4 application. Unfortately I cannot upgarde these to the latest versions because of which I am facing some issues with the p-dropdown component of primeng. The issue is documented and fixed in primeng 6.0.1 according to https://github.com/primefaces/primeng/issues/5915 .

Is there a way to fix this in primeng 5.2.7?

You can try to override bindDocumentClickListener() method form primeng Dropdown and make the same change as it is in: https://github.com/primefaces/primeng/commit/bbd66dfd15275761be9aa3e757825d32f0f6f531

This should like:

Dropdown.prototype.bindDocumentClickListener = function() {
    if(!this.documentClickListener) {
        this.documentClickListener = this.renderer.listen('document', 'click', () => {
            if(!this.selfClick&&!this.itemClick) {
                this.hide();
                this.unbindDocumentClickListener();
            }

            this.selfClick = false;
            this.itemClick = false;
            this.cd.markForCheck();
        });
    }
}

But you should also check if hide() method exists for primeng version which you are using in Dropdown component.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM