Skip to content

refactor: Remove duplicate layout components and fix memory leaks#95

Merged
PhantomDave merged 3 commits into
proper-dashboards-uifrom
copilot/sub-pr-94
Nov 24, 2025
Merged

refactor: Remove duplicate layout components and fix memory leaks#95
PhantomDave merged 3 commits into
proper-dashboards-uifrom
copilot/sub-pr-94

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 24, 2025

Addresses code review feedback from PR #94: duplicate layout components violating DRY, memory leaks from unsubscribed observables, and missing keyboard accessibility handlers.

Changes

  • Removed duplicate layout components: HomeLayoutComponent, MovementsLayoutComponent, and AnalyticsLayoutComponent were identical wrappers containing only <router-outlet />. Routes now reference child components directly.

  • Fixed memory leaks: Router event subscriptions in BreadcrumbComponent and SideNavComponent now use takeUntilDestroyed() from @angular/core/rxjs-interop for automatic cleanup.

  • Added keyboard accessibility: Theme toggle and logout buttons now handle keydown.enter and keydown.space events with preventDefault() to support keyboard navigation without double-triggering.

Before (routes.ts):

{
  path: 'home',
  component: HomeLayoutComponent,  // Unnecessary wrapper
  children: [...]
}

After:

{
  path: 'home',
  children: [...]  // Direct child routes
}

Before (subscriptions):

ngOnInit(): void {
  this.router.events
    .pipe(filter(...))
    .subscribe(...);  // Never unsubscribed
}

After:

constructor() {
  this.router.events
    .pipe(filter(...), takeUntilDestroyed())
    .subscribe(...);
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 24, 2025 15:56
…ts and fix accessibility

Co-authored-by: PhantomDave <34485699+PhantomDave@users.noreply.github.com>
Co-authored-by: PhantomDave <34485699+PhantomDave@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor routing and layout components for improved navigation refactor: Remove duplicate layout components and fix memory leaks Nov 24, 2025
Copilot AI requested a review from PhantomDave November 24, 2025 16:01
@PhantomDave PhantomDave marked this pull request as ready for review November 24, 2025 16:02
Copilot AI review requested due to automatic review settings November 24, 2025 16:02
@PhantomDave PhantomDave merged commit 4fac876 into proper-dashboards-ui Nov 24, 2025
7 checks passed
@PhantomDave PhantomDave deleted the copilot/sub-pr-94 branch November 24, 2025 16:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses technical debt and improves code quality by removing redundant layout components, fixing memory leaks, and enhancing keyboard accessibility. The changes align with Angular best practices for the zoneless, signal-based architecture used in this application.

Key Changes:

  • Eliminated three duplicate layout wrapper components (HomeLayoutComponent, MovementsLayoutComponent, AnalyticsLayoutComponent) that only contained <router-outlet />, simplifying the routing structure
  • Fixed memory leaks in BreadcrumbComponent and SideNavComponent by applying takeUntilDestroyed() to router event subscriptions
  • Added keyboard navigation support (Enter and Space keys) to theme toggle and logout buttons

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
frontend/src/app/layouts/home-layout/home-layout.component.ts Removed redundant wrapper component containing only <router-outlet />
frontend/src/app/layouts/movements-layout/movements-layout.component.ts Removed redundant wrapper component containing only <router-outlet />
frontend/src/app/layouts/analytics-layout/analytics-layout.component.ts Removed redundant wrapper component containing only <router-outlet />
frontend/src/app/app.routes.ts Removed references to deleted layout components from route configurations
frontend/src/app/components/ui-library/breadcrumb/breadcrumb.component.ts Added takeUntilDestroyed() to router subscription for automatic cleanup; moved subscription to constructor
frontend/src/app/components/side-nav-component/side-nav-component.ts Added takeUntilDestroyed() to router subscription; removed unnecessary OnInit implementation; moved subscription to constructor
frontend/src/app/components/side-nav-component/side-nav-component.html Added keydown.enter and keydown.space handlers with preventDefault() to theme toggle and logout buttons for keyboard accessibility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants