Skip to content

fix(login): rename AfterViewInit hook to ngAfterViewInit and fix rxjs internal import in interceptor#333

Open
tarun-227 wants to merge 3 commits into
PSMRI:mainfrom
tarun-227:fix/ngAfterViewInit-and-rxjs-internal-import
Open

fix(login): rename AfterViewInit hook to ngAfterViewInit and fix rxjs internal import in interceptor#333
tarun-227 wants to merge 3 commits into
PSMRI:mainfrom
tarun-227:fix/ngAfterViewInit-and-rxjs-internal-import

Conversation

@tarun-227
Copy link
Copy Markdown

@tarun-227 tarun-227 commented May 3, 2026

Summary

Two bugs across login.component.ts and http-interceptor.service.ts.


Bug 1 — Misnamed Angular lifecycle hook in login.component.ts

// Before — a plain public method, never called by Angular
export class LoginComponent implements OnInit {
  public AfterViewInit(): void {
    this.elementRef.nativeElement.focus();
  }
}

// After — correctly named lifecycle hook, called by Angular after view init
export class LoginComponent implements OnInit, AfterViewInit {
  ngAfterViewInit(): void {
    this.elementRef.nativeElement.focus();
  }
}

Angular calls lifecycle hooks by their conventional ng-prefixed name. The method was named AfterViewInit (capital A, no ng prefix), making it an ordinary public method that Angular never invokes. As a result, the @ViewChild('focus') element was never focused after the view initialised. Fixed by:

  1. Adding AfterViewInit to the @angular/core import
  2. Adding AfterViewInit to the implements clause
  3. Renaming the method to ngAfterViewInit

Bug 2 — throwError imported from RxJS internal path in http-interceptor.service.ts

// Before — private internal API, not guaranteed stable across RxJS minor versions
import { Observable, of, Subject, EMPTY } from 'rxjs';
import { throwError } from 'rxjs/internal/observable/throwError';

// After — public stable API; Subject removed (unused)
import { Observable, of, EMPTY, throwError } from 'rxjs';

rxjs/internal/* is not part of RxJS's public API contract. Importing from it can silently break on any minor or patch update. throwError has been exported from the top-level 'rxjs' package since RxJS 6. Subject was also imported but never referenced anywhere in the file, so it has been removed.

Summary by CodeRabbit

  • Bug Fixes
    • Login form now automatically receives focus when the page loads for improved usability.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

Warning

Rate limit exceeded

@tarun-227 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 33 minutes and 19 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 448be8e6-56e9-47ba-b12d-6e3fd29fbc61

📥 Commits

Reviewing files that changed from the base of the PR and between b668192 and 4c72465.

📒 Files selected for processing (1)
  • src/app/app-modules/login/login.component.ts
📝 Walkthrough

Walkthrough

The PR contains two independent changes: simplified RxJS imports in the HTTP interceptor service by removing an unused import and using the public throwError path, and fixes the login component's lifecycle hook by renaming AfterViewInit() to the correct ngAfterViewInit() and adding focus logic after view initialization.

Changes

HTTP Interceptor Import Optimization

Layer / File(s) Summary
Import Cleanup
src/app/app-modules/core/services/http-interceptor.service.ts
Removed unused Subject import. Changed throwError import from rxjs/internal/observable/throwError to the public rxjs package path.

Login Component Lifecycle Hook Implementation

Layer / File(s) Summary
Import Updates
src/app/app-modules/login/login.component.ts
Added AfterViewInit to Angular imports.
Class Declaration
src/app/app-modules/login/login.component.ts
Updated LoginComponent to declare implements OnInit, AfterViewInit.
Lifecycle Method
src/app/app-modules/login/login.component.ts
Renamed and corrected lifecycle hook from AfterViewInit(): void to ngAfterViewInit(): void with implementation that focuses the native element.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~8 minutes

A rabbit hops through the code with glee,
Imports cleaned up, hooks now work correctly,
Focus restored, the view shines so bright,
Small fixes that make the app work just right! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes both main changes: fixing the misnamed Angular lifecycle hook in login.component.ts and correcting the RxJS internal import in http-interceptor.service.ts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 33 minutes and 19 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/app/app-modules/login/login.component.ts`:
- Line 23: The `@angular/core` import line is failing Prettier: split the named
imports (Component, OnInit, AfterViewInit, ViewChild, ElementRef) onto multiple
lines with a trailing comma and consistent 2-space indentation so the import
from '@angular/core' conforms to the project's Prettier rules; update the import
statement that includes Component, OnInit, AfterViewInit, ViewChild, ElementRef
to use one-per-line (or multi-line) formatting with a trailing comma after the
last specifier.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 276a1a17-6840-433f-a6a5-3805268e16d7

📥 Commits

Reviewing files that changed from the base of the PR and between 22509ad and b668192.

📒 Files selected for processing (2)
  • src/app/app-modules/core/services/http-interceptor.service.ts
  • src/app/app-modules/login/login.component.ts

Comment thread src/app/app-modules/login/login.component.ts Outdated
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 3, 2026

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.

1 participant