Skip to content

Commit 59d1f93

Browse files
authored
refactor!: use empty string as default value for min and max (#4402)
1 parent 86ad67c commit 59d1f93

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

‎packages/time-picker/src/vaadin-time-picker.js‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import { PatternMixin } from '@vaadin/field-base/src/pattern-mixin.js';
1414
import { inputFieldShared } from '@vaadin/field-base/src/styles/input-field-shared-styles.js';
1515
import { registerStyles, ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
1616

17+
const MIN_ALLOWED_TIME = '00:00:00.000';
18+
const MAX_ALLOWED_TIME = '23:59:59.999';
19+
1720
registerStyles('vaadin-time-picker', inputFieldShared, { moduleId: 'vaadin-time-picker-styles' });
1821

1922
/**
@@ -166,7 +169,7 @@ class TimePicker extends PatternMixin(InputControlMixin(ThemableMixin(ElementMix
166169
*/
167170
min: {
168171
type: String,
169-
value: '00:00:00.000',
172+
value: '',
170173
},
171174

172175
/**
@@ -180,7 +183,7 @@ class TimePicker extends PatternMixin(InputControlMixin(ThemableMixin(ElementMix
180183
*/
181184
max: {
182185
type: String,
183-
value: '23:59:59.999',
186+
value: '',
184187
},
185188

186189
/**
@@ -485,10 +488,10 @@ class TimePicker extends PatternMixin(InputControlMixin(ThemableMixin(ElementMix
485488

486489
/** @private */
487490
__updateDropdownItems(i8n, min, max, step) {
488-
const minTimeObj = this.__validateTime(this.__parseISO(min));
491+
const minTimeObj = this.__validateTime(this.__parseISO(min || MIN_ALLOWED_TIME));
489492
const minSec = this.__getSec(minTimeObj);
490493

491-
const maxTimeObj = this.__validateTime(this.__parseISO(max));
494+
const maxTimeObj = this.__validateTime(this.__parseISO(max || MAX_ALLOWED_TIME));
492495
const maxSec = this.__getSec(maxTimeObj);
493496

494497
this.__adjustValue(minSec, maxSec, minTimeObj, maxTimeObj);
@@ -665,8 +668,8 @@ class TimePicker extends PatternMixin(InputControlMixin(ThemableMixin(ElementMix
665668
* @protected
666669
*/
667670
_timeAllowed(time) {
668-
const parsedMin = this.i18n.parseTime(this.min);
669-
const parsedMax = this.i18n.parseTime(this.max);
671+
const parsedMin = this.i18n.parseTime(this.min || MIN_ALLOWED_TIME);
672+
const parsedMax = this.i18n.parseTime(this.max || MAX_ALLOWED_TIME);
670673

671674
return (
672675
(!this.__getMsec(parsedMin) || this.__getMsec(time) >= this.__getMsec(parsedMin)) &&

‎packages/time-picker/test/time-picker.test.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,12 +351,12 @@ describe('time-picker', () => {
351351
});
352352

353353
describe('min and max properties', () => {
354-
it('min property should be 00:00:00.000 by default', () => {
355-
expect(timePicker.min).to.be.equal('00:00:00.000');
354+
it('min property should be empty by default', () => {
355+
expect(timePicker.min).to.be.equal('');
356356
});
357357

358-
it('max property should be 23:59:59.999 by default', () => {
359-
expect(timePicker.max).to.be.equal('23:59:59.999');
358+
it('max property should be empty by default', () => {
359+
expect(timePicker.max).to.be.equal('');
360360
});
361361

362362
it('should have dropdown items if min nor max is defined', () => {

0 commit comments

Comments
 (0)