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

p-ColumnFilter : Change of translation for custom filter take in account too late (randomly). #14273

Closed
Gwenou opened this issue Dec 4, 2023 · 1 comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@Gwenou
Copy link

Gwenou commented Dec 4, 2023

Describe the bug

When we use custom filter in the p-ColumnFilter we should pass the translation in the input matchModeOptions.

When the translation change we should change this value. For that we can subscribe on event like that in the parent component:

        this.translationSubscription = this.config.translationObserver.subscribe(() => {
            this.matchModeOptions =
                  customOption?.map((key: string) => {
                      return { label: this.translateService.instant("primeng." + key), value: key };
                  });
        });

But on the other side in the p-ColumnFilter the matchModeOptions is use in another subscribe:

        this.translationSubscription = this.config.translationObserver.subscribe(() => {
            this.generateMatchModeOptions();
            this.generateOperatorOptions();
        });

....

    generateMatchModeOptions() {
        this.matchModes =
            this.matchModeOptions ||
            (this.config as any).filterMatchModeOptions[this.type]?.map((key: any) => {
                return { label: this.config.getTranslation(key), value: key };
            });
    }

So if the subcribe in the p-ColumnFilter react in first the componement take the old value of the matchModeOptions and store it in matchModes. The parent component subscribe react and take in account new langage)
=> Result : the change of the matchModeOptions is not take in account and translation appear as the previous langage selected.

In conclusion in p-ColumnFilter an ngOnChanges function is missing to react on the change of matchModeOptions:

  ngOnChanges(changes: SimpleChanges) {
    if (changes.matchModeOptions) {
      this.generateMatchModeOptions();
    }
  }

Environment

I produce the bug localy on my dev environment.

Reproducer

No response

Angular version

16.2.10

PrimeNG version

16.5.1

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

16.16.0

Browser(s)

Edge

Steps to reproduce the behavior

No response

Expected behavior

No response

@Gwenou Gwenou added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 4, 2023
@mertsincan
Copy link
Member

Hi,

So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you reopen the issue so we can include it in our roadmap?
Please don't forget to add your feedback as a comment after reopening the issue. These will be taken into account by us and will contribute to the development of this feature. Thanks a lot for your understanding!

Best Regards,

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

2 participants