0

Please or Register to create posts and topics.

Problem with the mat accordion

Hi,

I use a mat accordion as well as in the Setting Module. But I want to prevent, then reopen the last displayed fragment is displayed again.
How can I prevent this?
I tried in dialogRef.afterClosed () with

const pathWithoutHash = this.location.path (false);
this.location.replaceState (pathWithoutHash);

to remove the fragment. The url will now display correctly, but when I open the dialog again, the last opened panel is displayed again.

Hi,

This line from settings.component.ts opens the appropriate feature based on the value of the url fragment. You can edit it to achieve your required behavior

ngOnInit() {
  this.fragmentSubscription = this.route.fragment.subscribe(anchor => {
    switch ((anchor || '').toLowerCase()) {
      case 'preferences':
        this.preferencesPanel.open();
        break;
      default:
        this.profilePanel.open();
    }
  });
}

Also you can use something like this.panelName.open() in ngOnInit to always force open a particular panel when displaying your panels

Regards,
Eben Monney

 

Ingo has reacted to this post.
Ingo

Thank you the tip was very helpful!

 

regards Ingo