ngx-bootstrap icon indicating copy to clipboard operation
ngx-bootstrap copied to clipboard

Angular Zoneless Change

Open spdocumentad opened this issue 1 year ago • 6 comments

Modal and Popover not working with zoneless or signal

spdocumentad avatar Sep 19 '24 11:09 spdocumentad

+1

inlooxgroup avatar Dec 11 '24 16:12 inlooxgroup

Positioning on ngZone.onStable.subscribe... cannot be used anymore:

https://angular.dev/guide/experimental/zoneless#remove-ngzoneonmicrotaskempty-ngzoneonunstable-ngzoneisstable-or-ngzoneonstable

I'm referring to this line: https://github.com/valor-software/ngx-bootstrap/blob/c31c3caf63011743d4ce1adb185cf319a37fcc79/src/component-loader/component-loader.class.ts#L366

inlooxgroup avatar Dec 11 '24 17:12 inlooxgroup

I am having similar issue with Typeahead

ed4becky avatar Mar 15 '25 12:03 ed4becky

When using provideZonelessChangeDetection() popovers and tooltips aren't positioned correctly. Seems to be related to the code snipped ghost referenced. I am still using provideZoneChangeDetection() for now, but hope this can be resolved in the near future.

nielswitte avatar Oct 22 '25 13:10 nielswitte

This is still an issue and will become more and more noticeable when people switch to Angular 21, which promotes Zoneless, and uses this as the default for new projects.

The issues we are seeing:

  • tooltip not positioned correctly
  • dropdown not positioned correctly Both fix themselves after scrolling, as the Positioning Service will listen to scroll events.

PapaNappa avatar Nov 27 '25 09:11 PapaNappa

I could fix the tooltip issue with the following directive:

import {Directive, inject} from '@angular/core';
import {PositioningService} from 'ngx-bootstrap/positioning';
import {TooltipDirective} from 'ngx-bootstrap/tooltip';

@Directive({
  // eslint-disable-next-line @angular-eslint/directive-selector
  selector: '[tooltip]',
  hostDirectives: [{directive: TooltipDirective, inputs: ['tooltip', 'delay']}],
})
export class TooltipFix {
  private readonly positioningService = inject(PositioningService);
  private readonly tooltipDirective = inject(TooltipDirective);

  constructor() {
    this.tooltipDirective.onShown.subscribe(() =>
      requestAnimationFrame(() => this.positioningService.calcPosition()),
    );
  }
}

In your components using the tooltip, replace the import TooltipModule (or TooltipDirective) with TooltipFix. Add more inputs/outputs as necessary.

PapaNappa avatar Nov 27 '25 09:11 PapaNappa