Skip to content

Commit

Permalink
fix(module:time-picker): scroll to wrong position in datepicker (#4961)
Browse files Browse the repository at this point in the history
* fix(module:time-picker): scroll to wrong position in datepicker

* chore: add style to ul element
  • Loading branch information
wenqi73 authored Apr 3, 2020
1 parent 70b2fc3 commit cdf387f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions components/time-picker/time-picker-panel.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ describe('time-picker-panel', () => {
listOfSelectContainer[1].querySelector('.ant-picker-time-panel-cell-selected .ant-picker-time-panel-cell-inner').textContent
).toContain(now.getMinutes().toString());
});

it('should offsetTop is right', fakeAsync(() => {
testComponent.value = new Date(0, 0, 0, 0, 0, 0);
fixture.detectChanges();
flush();
fixture.detectChanges();
const listOfSelectedLi = panelElement.nativeElement.querySelector('.ant-picker-time-panel-cell-selected');
expect(listOfSelectedLi.offsetTop).toBe(0);
}));
});
describe('disabled time-picker-panel', () => {
let fixture: ComponentFixture<NzTestTimePanelDisabledComponent>;
Expand Down
6 changes: 3 additions & 3 deletions components/time-picker/time-picker-panel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export type NzTimePickerUnit = 'hour' | 'minute' | 'second' | '12-hour';
<div class="ant-picker-header-view">{{ dateHelper.format(time?.value, format) || '&nbsp;' }}</div>
</div>
<div class="ant-picker-content">
<ul *ngIf="hourEnabled" #hourListElement class="{{ prefixCls }}-column">
<ul *ngIf="hourEnabled" #hourListElement class="{{ prefixCls }}-column" style="position: relative;">
<ng-container *ngFor="let hour of hourRange">
<li
*ngIf="!(nzHideDisabledOptions && hour.disabled)"
Expand All @@ -64,7 +64,7 @@ export type NzTimePickerUnit = 'hour' | 'minute' | 'second' | '12-hour';
</li>
</ng-container>
</ul>
<ul *ngIf="minuteEnabled" #minuteListElement class="{{ prefixCls }}-column">
<ul *ngIf="minuteEnabled" #minuteListElement class="{{ prefixCls }}-column" style="position: relative;">
<ng-container *ngFor="let minute of minuteRange">
<li
*ngIf="!(nzHideDisabledOptions && minute.disabled)"
Expand All @@ -79,7 +79,7 @@ export type NzTimePickerUnit = 'hour' | 'minute' | 'second' | '12-hour';
</li>
</ng-container>
</ul>
<ul *ngIf="secondEnabled" #secondListElement class="{{ prefixCls }}-column">
<ul *ngIf="secondEnabled" #secondListElement class="{{ prefixCls }}-column" style="position: relative;">
<ng-container *ngFor="let second of secondRange">
<li
*ngIf="!(nzHideDisabledOptions && second.disabled)"
Expand Down

0 comments on commit cdf387f

Please sign in to comment.