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

issue453: fix issue where hours and minutes fields are not updated when "enableKeyboardInput" is set to true #461

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file

## 13.1.2 (2024-01-02)

### Fixes

* fix(ngx-material-timepicker-component): fix issue where hours and minutes fields are not updated when "enableKeyboardInput" is set to true,
fixes [(#453)](https://github.com/Agranom/ngx-material-timepicker/issues/453)

## 13.1.1 (2023-07-11)

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ngx-material-timepicker",
"description": "Handy material design timepicker for angular",
"version": "13.1.1",
"version": "13.1.2",
"license": "MIT",
"author": "Vitalii Boiko <boyko330@gmail.com>",
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('NgxMaterialTimepickerDialControlComponent', () => {
}).createComponent(NgxMaterialTimepickerDialControlComponent);

component = fixture.componentInstance;
component.timeList = [];
});

it('should set current time to previous time, change time unit and emit focus event', waitForAsync(() => {
Expand Down Expand Up @@ -151,11 +152,19 @@ describe('NgxMaterialTimepickerDialControlComponent', () => {
it('should set value to form control', () => {
component.time = '10';
component.ngOnInit();
component.ngOnChanges();
const timeControl = component.timeControl;
expect(timeControl.value).toBe('10');
expect(timeControl.enabled).toBeTruthy();
});

it('should not set value to form control if form control is not available yet', () => {
component.time = '10';
component.ngOnChanges();
const timeControl = component.timeControl;
expect(timeControl).toBe(undefined);
});

it('should disable form control', () => {
component.disabled = true;
component.ngOnInit();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* tslint:disable:triple-equals */
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
import { Component, ElementRef, EventEmitter, Input, OnInit, OnChanges, Output, ViewChild } from '@angular/core';
import { FormControl } from '@angular/forms';
import { debounceTime, distinctUntilChanged, filter, tap } from 'rxjs/operators';
import { ClockFaceTime } from '../../models/clock-face-time.interface';
Expand All @@ -14,7 +14,7 @@ import { isDigit } from '../../utils/timepicker.utils';
styleUrls: ['ngx-material-timepicker-dial-control.component.scss'],
providers: [TimeParserPipe, TimeLocalizerPipe],
})
export class NgxMaterialTimepickerDialControlComponent implements OnInit {
export class NgxMaterialTimepickerDialControlComponent implements OnInit, OnChanges {

previousTime: number | string;

Expand Down Expand Up @@ -63,6 +63,12 @@ export class NgxMaterialTimepickerDialControlComponent implements OnInit {

}

ngOnChanges() {
if (this.timeControl) {
this.timeControl.setValue(this.formatTimeForUI(this.time));
}
}

saveTimeAndChangeTimeUnit(event: FocusEvent, unit: TimeUnit): void {
event.preventDefault();
this.previousTime = this.time;
Expand Down