Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Disable help text button on click

Alexander Brandon Coles59fb027bbfc1
diff --git a/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text-modal.service.spec.ts b/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text-modal.service.spec.ts
index b7b934de8f3..e2fa875d323 100644
--- a/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text-modal.service.spec.ts
+++ b/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text-modal.service.spec.ts
@@ -51,7 +51,7 @@ describe('AttributeHelpTextModalService', () => {
it('should make a request and handle Turbo Stream dialog response', async () => {
expect(document.querySelector('dialog')).toBeFalsy();
- modalService.show('1');
+ await modalService.show('1');
expect(fetchSpy).toHaveBeenCalledTimes(1);
diff --git a/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text-modal.service.ts b/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text-modal.service.ts
index 89751aaac8e..33771009941 100644
--- a/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text-modal.service.ts
+++ b/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text-modal.service.ts
@@ -39,8 +39,8 @@ export class AttributeHelpTextModalService {
}
- public show(helpTextId:string):void {
- void this.turboRequests.requestStream(this.helpTextModalUrl(helpTextId));
+ public show(helpTextId:string):Promise<unknown> {
+ return this.turboRequests.requestStream(this.helpTextModalUrl(helpTextId));
}
private helpTextModalUrl(helpTextId:string):string {
diff --git a/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text.component.html b/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text.component.html
index 818456a46af..3223efa49fb 100644
--- a/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text.component.html
+++ b/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text.component.html
@@ -4,6 +4,7 @@
[attr.id]="buttonId"
[attr.aria-labelledby]="tooltipId"
[attr.data-qa-help-text-for]="attribute"
+ [attr.aria-disabled]="isLoading"
(click)="handleClick($event)"
(keydown.enter)="handleClick($event)"
(keydown.space)="handleClick($event)"
diff --git a/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text.component.spec.ts b/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text.component.spec.ts
index 27ee0cacbdc..8d4889cec98 100644
--- a/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text.component.spec.ts
+++ b/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text.component.spec.ts
@@ -100,9 +100,32 @@ describe('AttributeHelpTextComponent', () => {
const button = element.query(By.css("[role='button']"));
button.nativeElement.click();
+ fixture.detectChanges();
+
+ expect(button.nativeElement.ariaDisabled).toEqual('true');
+
+ void fixture.whenStable().then(() => {
+ expect(modalServiceStub.show).toHaveBeenCalledOnceWith('1');
+ expect(button.nativeElement.ariaDisabled).toEqual('false');
+ });
+ });
+
+ it('should call modalService only once', () => {
+ const button = element.query(By.css("[role='button']"));
+ button.nativeElement.click();
+
+ fixture.detectChanges();
+
+ expect(button.nativeElement.ariaDisabled).toEqual('true');
+
+ button.nativeElement.click();
+ button.triggerEventHandler('keydown.enter');
+ button.triggerEventHandler('keydown.space');
+
fixture.detectChanges();
void fixture.whenStable().then(() => {
expect(modalServiceStub.show).toHaveBeenCalledOnceWith('1');
+ expect(button.nativeElement.ariaDisabled).toEqual('false');
});
});
});
diff --git a/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text.component.ts b/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text.component.ts
index d9186ed1c5a..6a2ed7bb1a7 100644
--- a/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text.component.ts
+++ b/frontend/src/app/shared/components/attribute-help-texts/attribute-help-text.component.ts
@@ -60,6 +60,8 @@ export class AttributeHelpTextComponent implements OnInit {
// Use single id entry if given
@Input() public helpTextId?:string|number;
+ isLoading = false;
+
readonly tooltipId = uniqueId('tooltip-');
readonly text = {
@@ -96,7 +98,15 @@ export class AttributeHelpTextComponent implements OnInit {
}
public handleClick(event:Event):void {
- void this.getId().then((id) => this.attributeHelpTextModalService.show(id));
+ if (this.isLoading) return;
+ this.isLoading = true;
+
+ void this.getId()
+ .then((id) => this.attributeHelpTextModalService.show(id))
+ .finally(() => {
+ this.isLoading = false;
+ this.cdRef.detectChanges();
+ });
event.preventDefault();
}
diff --git a/frontend/src/app/spot/styles/sass/components/link.sass b/frontend/src/app/spot/styles/sass/components/link.sass
index 51840c6666a..8471ef21253 100644
--- a/frontend/src/app/spot/styles/sass/components/link.sass
+++ b/frontend/src/app/spot/styles/sass/components/link.sass
@@ -22,6 +22,10 @@
cursor: default
color: inherit
+ &[aria-disabled=true]
+ cursor: default
+ color: var(--muted-color)
+
.spot-icon
&:first-child:not(:last-child)
margin-right: $spot-spacing-0_25