Skip to content

Commit

Permalink
114077: Fixed ViewChild not working correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrevryghem committed May 8, 2024
1 parent f5f00ca commit f738f97
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/app/profile-page/profile-page.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { BehaviorSubject, Observable } from 'rxjs';
import { EPerson } from '../core/eperson/models/eperson.model';
import { ProfilePageMetadataFormComponent } from './profile-page-metadata-form/profile-page-metadata-form.component';
import { ThemedProfilePageMetadataFormComponent } from './profile-page-metadata-form/themed-profile-page-metadata-form.component';
import { NotificationsService } from '../shared/notifications/notifications.service';
import { TranslateService } from '@ngx-translate/core';
import { Group } from '../core/eperson/models/group.model';
Expand Down Expand Up @@ -32,7 +32,7 @@ export class ProfilePageComponent implements OnInit {
/**
* A reference to the metadata form component
*/
@ViewChild(ProfilePageMetadataFormComponent) metadataForm: ProfilePageMetadataFormComponent;
@ViewChild(ThemedProfilePageMetadataFormComponent) metadataForm: ThemedProfilePageMetadataFormComponent;

/**
* The authenticated user as observable
Expand Down Expand Up @@ -114,8 +114,8 @@ export class ProfilePageComponent implements OnInit {
* Fire an update on both the metadata and security forms
* Show a warning notification when no changes were made in both forms
*/
updateProfile() {
const metadataChanged = this.metadataForm.updateProfile();
updateProfile(): void {
const metadataChanged = this.metadataForm.compRef.instance.updateProfile();
const securityChanged = this.updateSecurity();
if (!metadataChanged && !securityChanged) {
this.notificationsService.warning(
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/theme-support/themed.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { BASE_THEME_NAME } from './theme.constants';
export abstract class ThemedComponent<T> implements OnInit, OnDestroy, OnChanges {
@ViewChild('vcr', { read: ViewContainerRef }) vcr: ViewContainerRef;
@ViewChild('content') themedElementContent: ElementRef;
protected compRef: ComponentRef<T>;
compRef: ComponentRef<T>;

/**
* A reference to the themed component. Will start as undefined and emit every time the themed
Expand Down

0 comments on commit f738f97

Please sign in to comment.