Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 13, 2025

Closes #

Description

IgxTextHighlightDirective throws TypeError: Cannot set properties of undefined (setting 'searchText') when destroyed before ngAfterViewInit() completes. The error occurs because _lastSearchInfo is accessed in ngOnDestroy()clearHighlight() before being initialized.

// Before: Crashes on early destruction
ngOnDestroy() {
    this.clearHighlight();  // _lastSearchInfo is undefined
}

clearHighlight() {
    this._lastSearchInfo.searchText = '';  // TypeError
}

Changes

Added null guards to all _lastSearchInfo access points:

  • clearHighlight() - Guard property assignments
  • highlight() - Return 0 early if uninitialized
  • ngAfterViewChecked() - Guard condition check
  • searchNeedsEvaluation() - Return false early if uninitialized
// After: Safe at any lifecycle point
clearHighlight() {
    this.clearChildElements(false);
    if (this._lastSearchInfo) {
        this._lastSearchInfo.searchText = '';
        this._lastSearchInfo.matchCount = 0;
    }
}

Added tests covering early destruction and pre-initialization method calls.

Additional information (check all that apply):

  • Bug fix
  • New functionality
  • Documentation
  • Demos
  • CI/CD

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • accounts.google.com
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3693 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-29936633 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,14313495315228060282,5371148464022786279,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3692 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-21531927 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,10174059967038582203,3669025503131430136,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3694 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-82334969 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,12099313323146894926,15314719427062150155,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
  • android.clients.google.com
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3692 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-21531927 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,10174059967038582203,3669025503131430136,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --user-data-dir=/tmp/karma-21531927 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --no-sandbox --disable-gpu --window-size=820,800 --js-flags=--expose-gc --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=21531927 (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3694 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-82334969 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,12099313323146894926,15314719427062150155,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
  • clients2.google.com
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3692 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-21531927 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,10174059967038582203,3669025503131430136,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3693 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-29936633 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,14313495315228060282,5371148464022786279,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --user-data-dir=/tmp/karma-21531927 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --no-sandbox --disable-gpu --window-size=820,800 --js-flags=--expose-gc --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=21531927 (dns block)
  • content-autofill.googleapis.com
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3693 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-29936633 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,14313495315228060282,5371148464022786279,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --user-data-dir=/tmp/karma-29936633 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --no-sandbox --disable-gpu --window-size=820,800 --js-flags=--expose-gc --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=29936633 (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3694 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-82334969 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,12099313323146894926,15314719427062150155,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
  • milewalk.com
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3692 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-21531927 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,10174059967038582203,3669025503131430136,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --user-data-dir=/tmp/karma-21531927 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --no-sandbox --disable-gpu --window-size=820,800 --js-flags=--expose-gc --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=21531927 (dns block)
  • randomuser.me
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3693 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-29936633 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,14313495315228060282,5371148464022786279,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --user-data-dir=/tmp/karma-29936633 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --no-sandbox --disable-gpu --window-size=820,800 --js-flags=--expose-gc --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=29936633 (dns block)
  • redirector.gvt1.com
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3693 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-29936633 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,14313495315228060282,5371148464022786279,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3694 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-82334969 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,12099313323146894926,15314719427062150155,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3692 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-21531927 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,10174059967038582203,3669025503131430136,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
  • safebrowsing.googleapis.com
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3693 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-29936633 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,14313495315228060282,5371148464022786279,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --user-data-dir=/tmp/karma-29936633 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --no-sandbox --disable-gpu --window-size=820,800 --js-flags=--expose-gc --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=29936633 (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3694 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-82334969 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,12099313323146894926,15314719427062150155,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
  • update.googleapis.com
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3693 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-29936633 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,14313495315228060282,5371148464022786279,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3692 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-21531927 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,10174059967038582203,3669025503131430136,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --user-data-dir=/tmp/karma-29936633 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --no-sandbox --disable-gpu --window-size=820,800 --js-flags=--expose-gc --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=29936633 (dns block)
  • www.google.com
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3692 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-21531927 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,10174059967038582203,3669025503131430136,262144 --disable-features=PaintHolding --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --user-data-dir=/tmp/karma-21531927 --enable-automation --no-default-browser-check --no-first-run --disable-default-apps --disable-popup-blocking --disable-translate --disable-REDACTED-timer-throttling --disable-renderer-REDACTEDing --disable-device-discovery-notifications --no-sandbox --disable-gpu --window-size=820,800 --js-flags=--expose-gc --headless --disable-gpu --disable-dev-shm-usage --remote-debugging-port=9222 --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl http://localhost:9876/?id=21531927 (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-136.0.7103.94/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --crashpad-handler-pid=3693 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/karma-29936633 --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,14313495315228060282,5371148464022786279,262144 --disable-features=PaintHolding --variations-seed-version (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>IgxTextHighlightDirective throws TypeError when destroyed before ngAfterViewInit completes</issue_title>
<issue_description>## Description
The IgxTextHighlightDirective throws a TypeError: Cannot set properties of undefined (setting 'searchText') when the directive is destroyed before its view initialization completes. This occurs when components containing the directive are destroyed
during Angular's change detection cycle before ngAfterViewInit() has been called.

The error occurs in the clearHighlight() method which is called from ngOnDestroy(). The method attempts to access this._lastSearchInfo.searchText and this._lastSearchInfo.matchCount, but _lastSearchInfo is only initialized in
ngAfterViewInit(). If ngOnDestroy() is called before ngAfterViewInit() completes, _lastSearchInfo remains undefined, causing the error.

Error Stack Trace:
TypeError: Cannot set properties of undefined (setting 'searchText')
at _IgxTextHighlightDirective.clearHighlight (infragistics-igniteui-angular.mjs:38551:26)
at _IgxTextHighlightDirective.ngOnDestroy (infragistics-igniteui-angular.mjs:38472:10)
at executeOnDestroys (debug_node.mjs:7661:32)
at cleanUpView (debug_node.mjs:7526:9)
at destroyViewTree (debug_node.mjs:7463:21)
at destroyLView (debug_node.mjs:7500:5)

Problematic Code (from infragistics-igniteui-angular.mjs):

ngOnDestroy() {
    this.clearHighlight();  // Calls clearHighlight before checking initialization
    // ...
}

clearHighlight() {
    this.clearChildElements(false);
    this._lastSearchInfo.searchText = '';  // ERROR: No null check
    this._lastSearchInfo.matchCount = 0;   // ERROR: No null check
}

ngAfterViewInit() {
    // ...
    this._lastSearchInfo = {  // Only initialized here
        searchText: '',
        content: this.value,
        matchCount: 0,
        caseSensitive: false,
        exactMatch: false
    };
}

Steps to reproduce

  1. Create an Angular application with components that use IgxTextHighlightDirective (e.g., tree nodes, list items with search highlighting)
  2. Dynamically create and destroy these components rapidly (e.g., routing between views, conditionally rendering with *ngIf)
  3. Ensure the components are destroyed during Angular's change detection before their ngAfterViewInit() lifecycle hook completes
  4. Observe the console error: TypeError: Cannot set properties of undefined (setting 'searchText')

Result

The application throws a TypeError when IgxTextHighlightDirective is destroyed before initialization completes. The error propagates to the global error handler, potentially causing error loops or degraded user experience.

Expected result

The IgxTextHighlightDirective should safely handle being destroyed at any point in its lifecycle, including before ngAfterViewInit() completes. The clearHighlight() method should check if _lastSearchInfo exists before accessing its properties.

Proposed Fix:

 clearHighlight() {
     this.clearChildElements(false);
     if (this._lastSearchInfo) {  // Add null check
         this._lastSearchInfo.searchText = '';
         this._lastSearchInfo.matchCount = 0;
     }
 }
```</issue_description>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix IgxTextHighlightDirective TypeError on destroy Fix TypeError in IgxTextHighlightDirective when destroyed before initialization Nov 13, 2025
Copilot AI requested a review from dkalinovInfra November 13, 2025 16:03
Copilot finished work on behalf of dkalinovInfra November 13, 2025 16:03
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.

IgxTextHighlightDirective throws TypeError when destroyed before ngAfterViewInit completes

2 participants