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

Use querySelector if we only need first Element

Alexander Brandon Coles2dd3c443a26b
diff --git a/frontend/src/app/core/current-user/current-user.module.ts b/frontend/src/app/core/current-user/current-user.module.ts
index 5fb26d3f90d..125ee43f479 100644
--- a/frontend/src/app/core/current-user/current-user.module.ts
+++ b/frontend/src/app/core/current-user/current-user.module.ts
@@ -6,7 +6,7 @@ import { CurrentUserQuery } from './current-user.query';
import { firstValueFrom } from 'rxjs';
function loadUserMetadata(currentUserService:CurrentUserService) {
- const userMeta = document.querySelectorAll('meta[name=current_user]')[0] as HTMLElement|undefined;
+ const userMeta = document.querySelector<HTMLMetaElement>('meta[name=current_user]');
currentUserService.setUser({
id: userMeta?.dataset.id || null,
name: userMeta?.dataset.name || null,
diff --git a/frontend/src/app/shared/components/resizer/resizer/wp-resizer.component.ts b/frontend/src/app/shared/components/resizer/resizer/wp-resizer.component.ts
index 3393c8e2676..60c433a5b22 100644
--- a/frontend/src/app/shared/components/resizer/resizer/wp-resizer.component.ts
+++ b/frontend/src/app/shared/components/resizer/resizer/wp-resizer.component.ts
@@ -188,7 +188,7 @@ export class WpResizerDirective extends UntilDestroyedMixin implements OnInit, A
return undefined;
}
private applyColumnLayout(checkWidth = 750) {
- const singleView = document.querySelectorAll("[data-selector='wp-single-view']")[0] as HTMLElement;
+ const singleView = document.querySelector<HTMLElement>("[data-selector='wp-single-view']");
if (singleView) {
jQuery(singleView).toggleClass('work-package--single-view_with-columns', singleView.offsetWidth > checkWidth);
}
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.ts
index 2a5e4dc3153..1be7bbd715b 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
@@ -158,9 +158,9 @@ export class SpotDropModalComponent implements OnDestroy {
window.addEventListener('resize', this.onResize);
window.addEventListener('orientationchange', this.onResize);
- const focusCatcherContainer = document.querySelectorAll("[data-modal-focus-catcher-container='true']")[0];
+ const focusCatcherContainer = document.querySelector<HTMLElement>("[data-modal-focus-catcher-container='true']");
if (focusCatcherContainer) {
- (findAllFocusableElementsWithin(focusCatcherContainer as HTMLElement)[0])?.focus();
+ (findAllFocusableElementsWithin(focusCatcherContainer)[0])?.focus();
} else {
// Index 1 because the element at index 0 is the trigger button to open the modal
(findAllFocusableElementsWithin(document.querySelector('.spot-drop-modal-portal')!)[1])?.focus();