diff --git a/components/date-picker/date-range-popup.component.ts b/components/date-picker/date-range-popup.component.ts index c463c7dc505..377747c562e 100644 --- a/components/date-picker/date-range-popup.component.ts +++ b/components/date-picker/date-range-popup.component.ts @@ -56,7 +56,7 @@ import { getTimeConfig, isAllowedDate, PREFIX_CLASS } from './util'; template: `
-
+
@@ -179,6 +179,12 @@ export class DateRangePopupComponent implements OnInit, OnChanges, OnDestroy { return this.showToday || this.hasTimePicker || !!this.extraFooter || !!this.ranges; } + get arrowPosition(): { left?: string; right?: string } { + return this.dir === 'rtl' + ? { right: `${this.datePickerService?.arrowLeft}px` } + : { left: `${this.datePickerService?.arrowLeft}px` }; + } + constructor( public datePickerService: DatePickerService, public cdr: ChangeDetectorRef, diff --git a/components/date-picker/range-picker.component.spec.ts b/components/date-picker/range-picker.component.spec.ts index 18f8498a1d6..05e4cc8e0a7 100644 --- a/components/date-picker/range-picker.component.spec.ts +++ b/components/date-picker/range-picker.component.spec.ts @@ -410,6 +410,31 @@ describe('NzRangePickerComponent', () => { const result = (nzOnChange.calls.allArgs()[0] as Date[][])[0]; expect((result[0] as Date).getDate()).toBe(+leftText); })); + + it('should support correct position for top arrow', fakeAsync(() => { + fixture.detectChanges(); + openPickerByClickTrigger(); + fixture.detectChanges(); + flush(); + fixture.detectChanges(); + const arrow = queryFromOverlay(`.${PREFIX_CLASS}-range-arrow`) as HTMLElement; + + expect(arrow.style.left).not.toBe(''); + })); + + it('should support dir rtl for top arrow', fakeAsync(() => { + fixture.debugElement.nativeElement.parentElement.setAttribute('dir', 'rtl'); + fixture.detectChanges(); + openPickerByClickTrigger(); + fixture.detectChanges(); + flush(); + fixture.detectChanges(); + const arrow = queryFromOverlay(`.${PREFIX_CLASS}-range-arrow`) as HTMLElement; + + expect(arrow.style.right).not.toBe(''); + expect(arrow.style.left).toBe(''); + fixture.debugElement.nativeElement.parentElement.setAttribute('dir', ''); + })); }); // /general api testing describe('panel switch and move forward/afterward', () => {