Skip to content

Commit

Permalink
fix(components/datetime): timepicker minute picker highlights closest…
Browse files Browse the repository at this point in the history
… passed time (#2900)
  • Loading branch information
Blackbaud-SandhyaRajasabeson authored Nov 15, 2024
1 parent b471e0e commit b85231e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@
<button
name="minute"
type="button"
[ngClass]="{ 'sky-btn-active': selectedMinute === minute }"
[ngClass]="{
'sky-btn-active': highlightMinute(selectedMinute, minute)
}"
(click)="setTime($event)"
>
{{ '00'.substring(0, 2 - minute.toString().length) + minute }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,19 @@ describe('Timepicker', () => {
expect(component.selectedTime?.local).toEqual('2:55 AM');
}));

it('should highlight the minute that is the passed multiple of five in the picker', fakeAsync(() => {
detectChangesAndTick(fixture);
setInput('2:33 AM', fixture);
openTimepicker(fixture);

const timepicker = getTimepicker();
const highlightedMinute = timepicker.querySelector(
'button[name="minute"].sky-btn-active',
);

expect(highlightedMinute).toHaveText('30');
}));

it('should handle undefined date', fakeAsync(() => {
detectChangesAndTick(fixture);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ export class SkyTimepickerComponent implements OnInit, OnDestroy {
this.#openPicker();
}

protected highlightMinute(selectedMinute: number, minute: number): boolean {
return Math.floor(selectedMinute / 5) === minute / 5;
}

#closePicker(): void {
this.#destroyAffixer();
this.#destroyOverlay();
Expand Down

0 comments on commit b85231e

Please sign in to comment.