Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(datePicker): thy-year-picker does not have a default time, when i… #2836

Merged
merged 3 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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