Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,10 @@ export class RiskAssessmentComponent
saveProfileClicked(profile: Profile, selectedProfile: Profile | null): void {
this.liveAnnouncer.clear();
if (!selectedProfile) {
this.saveProfile(profile, this.store.setFocusOnCreateButton);
this.saveProfile(profile, () => {
this.store.setFocusOnCreateButton();
this.store.scrollToSelectedProfile();
});
} else if (
this.compareProfiles(profile, selectedProfile) ||
this.isCopyProfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,21 +197,28 @@ describe('RiskAssessmentStore', () => {
}));
});

describe('setFocusOnSelectedProfile', () => {
describe('with selected profile', () => {
const container = document.createElement('div') as HTMLElement;
container.classList.add('entity-list');
const inner = document.createElement('div') as HTMLElement;
inner.classList.add('selected');
container.appendChild(inner);
document.querySelector('body')?.appendChild(container);

it('should call focusFirstElementInContainer', () => {
it('setFocusOnSelectedProfile should call focusFirstElementInContainer', () => {
riskAssessmentStore.setFocusOnSelectedProfile();

expect(
mockFocusManagerService.focusFirstElementInContainer
).toHaveBeenCalledWith(inner);
});

it('scrollToSelectedProfile should call focusFirstElementInContainer', () => {
const scrollSpy = spyOn(inner, 'scrollIntoView');
riskAssessmentStore.scrollToSelectedProfile();

expect(scrollSpy).toHaveBeenCalled();
});
});

describe('setFocusOnProfileForm', () => {
Expand Down
10 changes: 10 additions & 0 deletions modules/ui/src/app/pages/risk-assessment/risk-assessment.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ export class RiskAssessmentStore extends ComponentStore<AppComponentState> {
);
});

scrollToSelectedProfile = this.effect(trigger$ => {
return trigger$.pipe(
tap(() => {
window.document
.querySelector('.entity-list .selected')
?.scrollIntoView();
})
);
});

setFocusOnProfileForm = this.effect(trigger$ => {
return trigger$.pipe(
tap(() => {
Expand Down
1 change: 0 additions & 1 deletion modules/ui/src/app/services/local-storage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export class LocalStorageService {

getGAConsent() {
const consent = this.getItem(this.GA_CONSENT_KEY);
console.log(window.localStorage.getItem(this.GA_CONSENT_KEY));
return consent !== null ? consent === 'true' : true;
}

Expand Down