Skip to content

Commit ab258b3

Browse files
author
Alex Umanskiy
committed
chore(providers): fixed typeahead error
1 parent ed0932c commit ab258b3

4 files changed

Lines changed: 30 additions & 25 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
32
## [21.2.0](https://github.com/valor-software/ngx-bootstrap/compare/v21.0.1...v21.2.0) (2025-04-13)
43

54
### BREAKING CHANGES
@@ -9,6 +8,8 @@
98
* **inputs:** All `@Input()` decorators have been replaced with the `input()` signal function API. Programmatic access to component inputs now requires signal read syntax (e.g., `component.myInput()` instead of `component.myInput`).
109
* **outputs:** All `@Output()` decorators have been replaced with the `output()` function API. Output emissions continue to use `.emit()`.
1110
* **services:** Removed `NgZone` dependency from carousel, component-loader, positioning service, and focus-trap. Replaced `NgZone.onStable` with `afterRenderEffect()`.
11+
* **modules:** Removed deprecated `forRoot()` static method from all 17 module classes (AccordionModule, AlertModule, ButtonsModule, CarouselModule, CollapseModule, BsDatepickerModule, BsDropdownModule, FocusTrapModule, PaginationModule, PopoverModule, ProgressbarModule, RatingModule, SortableModule, TabsModule, TimepickerModule, TooltipModule, TypeaheadModule). These methods were no-ops returning empty providers and were deprecated since v18. Simply use the module directly in imports (e.g., `TooltipModule` instead of `TooltipModule.forRoot()`).
12+
* **schematics:** `ng add` schematics now generate module imports without `.forRoot()`.
1213

1314
### Features
1415

apps/ngx-bootstrap-docs/src/ng-api-doc.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,81 +1736,82 @@ export const ngdoc: any = {
17361736
},
17371737
{
17381738
name: 'show',
1739-
description:
1740-
'<p>Opens an element&#39;s popover. This is considered a &quot;manual&quot; triggering of\nthe popover.</p>\n',
1739+
description: '<p>Opens an element’s popover. This is considered a “manual” triggering of\nthe popover.</p>\n',
17411740
args: [],
17421741
returnType: 'void'
17431742
},
17441743
{
17451744
name: 'hide',
1746-
description:
1747-
'<p>Closes an element&#39;s popover. This is considered a &quot;manual&quot; triggering of\nthe popover.</p>\n',
1745+
description: '<p>Closes an element’s popover. This is considered a “manual” triggering of\nthe popover.</p>\n',
17481746
args: [],
17491747
returnType: 'void'
17501748
},
17511749
{
17521750
name: 'toggle',
1753-
description:
1754-
'<p>Toggles an element&#39;s popover. This is considered a &quot;manual&quot; triggering of\nthe popover.</p>\n',
1751+
description: '<p>Toggles an element’s popover. This is considered a “manual” triggering of\nthe popover.</p>\n',
17551752
args: [],
17561753
returnType: 'void'
17571754
}
17581755
],
17591756
properties: [
17601757
{
17611758
name: 'adaptivePosition',
1762-
type: 'InputSignal<boolean>',
1759+
defaultValue: 'true',
1760+
type: 'boolean',
17631761
description: '<p>sets disable adaptive position</p>\n'
17641762
},
17651763
{
17661764
name: 'container',
1767-
type: 'InputSignal<string>',
1765+
type: 'string',
17681766
description: '<p>A selector specifying the element the popover should be appended to.</p>\n'
17691767
},
17701768
{
17711769
name: 'containerClass',
1772-
type: 'InputSignal<string>',
1770+
type: 'string',
17731771
description: '<p>Css class for popover container</p>\n'
17741772
},
17751773
{
17761774
name: 'delay',
1777-
type: 'InputSignal<number>',
1775+
defaultValue: '0',
1776+
type: 'number',
17781777
description: '<p>Delay before showing the tooltip</p>\n'
17791778
},
17801779
{
17811780
name: 'isOpen',
1782-
type: 'boolean',
1781+
type: 'ModelSignal<boolean>',
17831782
description: '<p>Returns whether or not the popover is currently being shown</p>\n'
17841783
},
17851784
{
17861785
name: 'onHidden',
1787-
type: 'EventEmitter<unknown>',
1786+
type: 'OutputEmitterRef<unknown>',
17881787
description: '<p>Emits an event when the popover is hidden</p>\n'
17891788
},
17901789
{
17911790
name: 'onShown',
1792-
type: 'EventEmitter<unknown>',
1791+
type: 'OutputEmitterRef<unknown>',
17931792
description: '<p>Emits an event when the popover is shown</p>\n'
17941793
},
17951794
{
17961795
name: 'outsideClick',
1797-
type: 'InputSignal<boolean>',
1796+
defaultValue: 'false',
1797+
type: 'boolean',
17981798
description: '<p>Close popover on outside click</p>\n'
17991799
},
18001800
{
18011801
name: 'placement',
1802-
type: 'InputSignal<AvailableBSPositions>',
1802+
defaultValue: 'top',
1803+
type: 'AvailableBSPositions',
18031804
description:
18041805
'<p>Placement of a popover. Accepts: &quot;top&quot;, &quot;bottom&quot;, &quot;left&quot;, &quot;right&quot;</p>\n'
18051806
},
18061807
{
18071808
name: 'popover',
1808-
type: 'InputSignal<string | TemplateRef<any>>',
1809+
type: 'string | TemplateRef<any>',
18091810
description: '<p>Content to be displayed as popover.</p>\n'
18101811
},
18111812
{
18121813
name: 'popoverContext',
1813-
type: 'InputSignal<any>',
1814+
type: 'any',
18141815
description: '<p>Context to be used if popover is a template.</p>\n'
18151816
},
18161817
{
@@ -1820,12 +1821,13 @@ export const ngdoc: any = {
18201821
},
18211822
{
18221823
name: 'popoverTitle',
1823-
type: 'InputSignal<string>',
1824+
type: 'string',
18241825
description: '<p>Title of a popover.</p>\n'
18251826
},
18261827
{
18271828
name: 'triggers',
1828-
type: 'InputSignal<string>',
1829+
defaultValue: 'click',
1830+
type: 'string',
18291831
description: '<p>Specifies events that should trigger. Supports a space separated list of\nevent names.</p>\n'
18301832
}
18311833
]

src/typeahead/typeahead-container.component.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import { typeaheadAnimation } from './typeahead-animations';
2323
import { TypeaheadOptionItemContext, TypeaheadOptionListContext, TypeaheadTemplateMethods } from './models';
2424
import { NgTemplateOutlet } from '@angular/common';
2525

26-
let nextWindowId = 0;
27-
2826
@Component({
2927
selector: 'typeahead-container',
3028
templateUrl: './typeahead-container.component.html',
@@ -71,7 +69,7 @@ export class TypeaheadContainerComponent implements OnDestroy {
7169
animationState?: string;
7270
positionServiceSubscription = new Subscription();
7371
height = 0;
74-
popupId = `ngb-typeahead-${nextWindowId++}`;
72+
popupId = '';
7573

7674
get typeaheadTemplateMethods(): TypeaheadTemplateMethods {
7775
return {
@@ -96,7 +94,6 @@ export class TypeaheadContainerComponent implements OnDestroy {
9694
public element: ElementRef,
9795
private changeDetectorRef: ChangeDetectorRef
9896
) {
99-
this.renderer.setAttribute(this.element.nativeElement, 'id', this.popupId);
10097
this.positionServiceSubscription.add(this.positionService.event$?.subscribe(
10198
() => {
10299
if (this.isAnimated) {

src/typeahead/typeahead.directive.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import { getValueFromObject, latinize, tokenize } from './typeahead-utils';
2626
import { TypeaheadConfig } from './typeahead.config';
2727
import { PositioningService } from 'ngx-bootstrap/positioning';
2828

29+
let nextWindowId = 0;
30+
2931
// eslint-disable-next-line
3032
type TypeaheadOption = string | Record<string | number, any>;
3133
type TypeaheadOptionArr = TypeaheadOption[] | Observable<TypeaheadOption>;
@@ -35,7 +37,7 @@ type TypeaheadOptionArr = TypeaheadOption[] | Observable<TypeaheadOption>;
3537
exportAs: 'bs-typeahead',
3638
host: {
3739
'[attr.aria-activedescendant]': 'activeDescendant',
38-
'[attr.aria-owns]': 'isOpen ? this._container?.popupId : null',
40+
'[attr.aria-owns]': 'isOpen ? popupId : null',
3941
'[attr.aria-expanded]': 'isOpen',
4042
'[attr.aria-autocomplete]': 'list'
4143
},
@@ -171,6 +173,7 @@ export class TypeaheadDirective implements OnInit, OnDestroy {
171173

172174
activeDescendant?: string;
173175
isOpen = false;
176+
popupId = `ngb-typeahead-${nextWindowId++}`;
174177
list = 'list';
175178
_container?: TypeaheadContainerComponent;
176179
isActiveItemChanged = false;
@@ -401,6 +404,8 @@ export class TypeaheadDirective implements OnInit, OnDestroy {
401404
}
402405

403406
this._container = this._typeahead.instance;
407+
this._container.popupId = this.popupId;
408+
this.renderer.setAttribute(this._container.element.nativeElement, 'id', this.popupId);
404409
this._container.parent = this;
405410
// This improves the speed as it won't have to be done for each list item
406411

0 commit comments

Comments
 (0)