Skip to content

Commit 0357a3a

Browse files
haryasalexasq
andauthored
fix(datepicker): share PositioningService instance (#6775)
Use a single shared PositioningService instance for the datepicker and daterangepicker directives to fix adaptive positioning issues: - Adaptive positioning on the daterangepicker now works. - Adaptive positioning on one datepicker no longer affects other instances. - Also apply this change to the inline datepicker and inline daterangepicker for consistency. Fixes #6773, fixes #6774 Co-authored-by: Alexey Umanskiy <[email protected]>
1 parent ca67d2a commit 0357a3a

7 files changed

+11
-11
lines changed

src/datepicker/bs-datepicker-inline.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from '@angular/core';
1515

1616
import { ComponentLoader, ComponentLoaderFactory } from 'ngx-bootstrap/component-loader';
17+
import { PositioningService } from 'ngx-bootstrap/positioning';
1718

1819
import { Subscription } from 'rxjs';
1920
import { BsDatepickerInlineConfig } from './bs-datepicker-inline.config';
@@ -28,7 +29,7 @@ import { checkBsValue, setCurrentTimeOnDateSelect } from './utils/bs-calendar-ut
2829
selector: 'bs-datepicker-inline',
2930
exportAs: 'bsDatepickerInline',
3031
standalone: true,
31-
providers: [ComponentLoaderFactory]
32+
providers: [ComponentLoaderFactory, PositioningService]
3233
})
3334
export class BsDatepickerInlineDirective implements OnInit, OnDestroy, OnChanges {
3435
/**

src/datepicker/bs-datepicker.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
ViewContainerRef
1515
} from '@angular/core';
1616
import { ComponentLoader, ComponentLoaderFactory } from 'ngx-bootstrap/component-loader';
17+
import { PositioningService } from 'ngx-bootstrap/positioning';
1718
import { BehaviorSubject, Observable, Subject, Subscription } from 'rxjs';
1819
import { filter, takeUntil } from 'rxjs/operators';
1920
import { BsDatepickerConfig } from './bs-datepicker.config';
@@ -27,7 +28,7 @@ export let previousDate: Date | Date[] | undefined;
2728
@Directive({
2829
selector: '[bsDatepicker]',
2930
exportAs: 'bsDatepicker',
30-
providers: [ComponentLoaderFactory],
31+
providers: [ComponentLoaderFactory, PositioningService],
3132
standalone: true
3233
})
3334
export class BsDatepickerDirective implements OnInit, OnDestroy, OnChanges, AfterViewInit {

src/datepicker/bs-daterangepicker-inline.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
} from '@angular/core';
55

66
import { ComponentLoader, ComponentLoaderFactory } from 'ngx-bootstrap/component-loader';
7+
import { PositioningService } from 'ngx-bootstrap/positioning';
78

89
import { Subscription } from 'rxjs';
910
import { filter } from 'rxjs/operators';
@@ -22,9 +23,7 @@ import {
2223
selector: 'bs-daterangepicker-inline',
2324
exportAs: 'bsDaterangepickerInline',
2425
standalone: true,
25-
providers: [
26-
ComponentLoaderFactory
27-
]
26+
providers: [ComponentLoaderFactory, PositioningService]
2827
})
2928
export class BsDaterangepickerInlineDirective implements OnInit, OnDestroy, OnChanges {
3029
_bsValue?: (Date|undefined)[] | undefined;

src/datepicker/bs-daterangepicker.component.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { BsDaterangepickerContainerComponent } from './themes/bs/bs-daterangepic
1010
import { Observable, Subscription, Subject, BehaviorSubject } from 'rxjs';
1111
import { filter, takeUntil } from 'rxjs/operators';
1212
import { ComponentLoaderFactory, ComponentLoader } from 'ngx-bootstrap/component-loader';
13+
import { PositioningService } from 'ngx-bootstrap/positioning';
1314
import { BsDatepickerConfig } from './bs-datepicker.config';
1415
import { DatepickerDateCustomClasses } from './models';
1516
import {
@@ -25,9 +26,7 @@ export let previousDate: (Date | undefined)[] | undefined;
2526
selector: '[bsDaterangepicker]',
2627
exportAs: 'bsDaterangepicker',
2728
standalone: true,
28-
providers: [
29-
ComponentLoaderFactory
30-
]
29+
providers: [ComponentLoaderFactory, PositioningService]
3130
})
3231
export class BsDaterangepickerDirective
3332
implements OnInit, OnDestroy, OnChanges, AfterViewInit {

src/datepicker/themes/bs/bs-datepicker-inline-container.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { NgIf, NgClass, NgSwitch, NgSwitchCase, NgFor, AsyncPipe } from '@angula
1717

1818
@Component({
1919
selector: 'bs-datepicker-inline-container',
20-
providers: [BsDatepickerStore, BsDatepickerEffects, PositioningService],
20+
providers: [BsDatepickerStore, BsDatepickerEffects],
2121
templateUrl: './bs-datepicker-view.html',
2222
host: {
2323
'(click)': '_stopPropagation($event)'

src/datepicker/themes/bs/bs-daterangepicker-container.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { NgIf, NgClass, NgSwitch, NgSwitchCase, NgFor, AsyncPipe } from '@angula
3434

3535
@Component({
3636
selector: 'bs-daterangepicker-container',
37-
providers: [BsDatepickerStore, BsDatepickerEffects, BsDatepickerActions, PositioningService],
37+
providers: [BsDatepickerStore, BsDatepickerEffects, BsDatepickerActions],
3838
templateUrl: './bs-datepicker-view.html',
3939
host: {
4040
class: 'bottom',

src/datepicker/themes/bs/bs-daterangepicker-inline-container.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { NgIf, NgClass, NgSwitch, NgSwitchCase, NgFor, AsyncPipe } from '@angula
1717

1818
@Component({
1919
selector: 'bs-daterangepicker-inline-container',
20-
providers: [BsDatepickerStore, BsDatepickerEffects, BsDatepickerActions, PositioningService],
20+
providers: [BsDatepickerStore, BsDatepickerEffects, BsDatepickerActions],
2121
templateUrl: './bs-datepicker-view.html',
2222
host: {
2323
'(click)': '_stopPropagation($event)'

0 commit comments

Comments
 (0)