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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix focus handling for the old wp datepicker modals
Benjamin Bädorfdd36a5b2344f
diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex b8b2a1893fa..3ad71960bd7 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -1347,4 +1347,5 @@ en:filter_chip:remove: 'Remove'drop_modal:+ focus_grab: 'This is a focus anchor for modals. Press shift+tab to go back to the modal trigger element.'Close: 'Close'diff --git a/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.html b/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.htmlindex f0c9f05ab9f..079ce668c23 100644--- a/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.html+++ b/frontend/src/app/shared/components/datepicker/wp-multi-date-form/wp-multi-date-form.component.html@@ -5,9 +5,6 @@#modalContainerdata-indicator-name="modal"tabindex="0"- cdkFocusInitial- cdkTrapFocus- [cdkTrapFocusAutoCapture]="true"(submit)="doSave($event)"><op-datepicker-bannerdiff --git a/frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.html b/frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.htmlindex f71676f8e4a..7a9117750bb 100644--- a/frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.html+++ b/frontend/src/app/shared/components/datepicker/wp-single-date-form/wp-single-date-form.component.html@@ -6,9 +6,6 @@data-indicator-name="modal"(submit)="doSave($event)"tabindex="0"- cdkFocusInitial- cdkTrapFocus- [cdkTrapFocusAutoCapture]="true"><op-datepicker-banner[scheduleManually]="scheduleManually"diff --git a/frontend/src/app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.component.ts b/frontend/src/app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.component.tsindex 7fafd0ee8b3..e0b74b8e985 100644--- a/frontend/src/app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.component.ts+++ b/frontend/src/app/shared/components/fields/edit/field-types/date-edit-field/date-edit-field.component.ts@@ -38,7 +38,6 @@ import { TimezoneService } from 'core-app/core/datetime/timezone.service';[(ngModel)]="value"[id]="handler.htmlId"class="inline-edit--field"- [opAutofocus]></op-single-date-picker>`,changeDetection: ChangeDetectionStrategy.OnPush,diff --git a/frontend/src/app/spot/components/drop-modal/drop-modal.component.html b/frontend/src/app/spot/components/drop-modal/drop-modal.component.htmlindex cf090a8ab11..02e96231ee5 100644--- a/frontend/src/app/spot/components/drop-modal/drop-modal.component.html+++ b/frontend/src/app/spot/components/drop-modal/drop-modal.component.html@@ -1,4 +1,9 @@<ng-content select="[slot=trigger]"></ng-content>+<span+ tabindex="0"+ #focusGrabber+ [attr.aria-label]="text.focus_grab"+></span><ng-template #body><div@@ -9,9 +14,7 @@><div[ngClass]="['spot-drop-modal--body', 'spot-container', alignmentClass]"-(click)="onBodyClick($event)"-cdkTrapFocustabindex="0">diff --git a/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts b/frontend/src/app/spot/components/drop-modal/drop-modal.component.tsindex b15d72bcc8f..8a4be61e3a5 100644--- a/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts+++ b/frontend/src/app/spot/components/drop-modal/drop-modal.component.ts@@ -113,10 +113,13 @@ export class SpotDropModalComponent implements OnDestroy {public text = {close: this.i18n.t('js.spot.drop_modal.close'),+ focus_grab: this.i18n.t('js.spot.drop_modal.focus_grab'),};@ViewChild('body') body:TemplateRef<any>;+ @ViewChild('focusGrabber') focusGrabber:ElementRef;+constructor(readonly i18n:I18nService,readonly elementRef:ElementRef,@@ -187,24 +190,9 @@ export class SpotDropModalComponent implements OnDestroy {window.removeEventListener('resize', this.onResize);window.removeEventListener('orientationchange', this.onResize);- this.teleportationService- .hasRenderedFiltered$- .pipe(- filter((hasRendered) => !hasRendered),- take(1),- )- .subscribe(() => {- // TODO: Because we're using input fields with focus event listeners as openers,- // we cannot just go back and focus the input field; that would result in infinite loops.- // The issue is that for keyboard and screenreader users, you get dropped back to the start- // of the page, which is an a11y nightmare.- //- // (findAllFocusableElementsWithin(this.elementRef.nativeElement)[0] as HTMLElement)?.focus();- // this.cdRef.detectChanges();- });-this.teleportationService.clear();this.cdRef.detectChanges();+ this.focusGrabber.nativeElement.focus();}private onGlobalClick = this.close.bind(this);