Skip to content

Commit

Permalink
fix(datePicker): thy-year-picker does not have a default time, when i… (
Browse files Browse the repository at this point in the history
#2836)

* fix(datePicker): thy-year-picker does not have a default time, when it open , throws an error.(#INFR-9345)

* fix: fix code review

* fix: fix code review
  • Loading branch information
mengshuicmq committed Sep 11, 2023
1 parent 09c7f1e commit 367c436
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/date-picker/lib/popups/date-popup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,10 +499,7 @@ export class DatePopupComponent implements OnChanges, OnInit {
const [start, end] = value;
const newStart = start || new TinyDate();
let newEnd = end;
if (!newEnd) {
newEnd = dateAddAmount(newStart, 1, headerMode);
}
if (newStart.isSame(end, headerMode as TinyDateCompareGrain)) {
if (!newEnd || newStart.isSame(end, headerMode as TinyDateCompareGrain)) {
newEnd = dateAddAmount(newStart, 1, headerMode);
}
return [newStart, newEnd];
Expand Down
10 changes: 10 additions & 0 deletions src/date-picker/range-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,7 @@ describe('ThyRangePickerComponent', () => {
expect(queryFromOverlay('.thy-calendar-range-right .thy-calendar-month')).toBeTruthy();
expect(queryFromOverlay('.thy-calendar-range-right .thy-calendar-month-btn').textContent.trim()).toEqual('2020年');
}));

it('should support previous and next year', fakeAsync(() => {
fixtureInstance.modelValue = { begin: new Date('2018-09-11'), end: new Date('2018-10-12') };
fixture.detectChanges();
Expand All @@ -693,6 +694,7 @@ describe('ThyRangePickerComponent', () => {
fixture.detectChanges();
expect(queryFromOverlay('.thy-calendar-range-left .thy-calendar-month-btn').textContent.indexOf('2018') > -1).toBeTruthy();
}));

it('should support panel changes', fakeAsync(() => {
fixtureInstance.modelValue = { begin: new Date('2018-09-11'), end: new Date('2018-10-12') };
fixture.detectChanges();
Expand Down Expand Up @@ -877,6 +879,14 @@ describe('ThyRangePickerComponent', () => {
expect(queryFromOverlay('.thy-calendar-picker-inner-popup').firstElementChild.className).toEqual('thy-calendar-month');
}));

it(`should set thyMode to year`, fakeAsync(() => {
fixture.detectChanges();
fixtureInstance.thyMode = 'year';
fixture.detectChanges();
openPickerByClickTrigger();
expect(queryFromOverlay('.thy-calendar-picker-inner-popup').firstElementChild.className).toEqual('thy-calendar-year');
}));

it(`should set thyMode to decade`, fakeAsync(() => {
fixture.detectChanges();
fixtureInstance.thyMode = 'decade';
Expand Down

1 comment on commit 367c436

@vercel
Copy link

@vercel vercel bot commented on 367c436 Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

tethys – ./

tethys-vert.vercel.app
tethys-git-master-tethys.vercel.app
tethys-tethys.vercel.app

Please sign in to comment.