Skip to content

Commit da30bc1

Browse files
authored
fix(ui5-duration-picker): make maxValue work with values greater than 23:59:59 (#1666)
1 parent 9cfcbbf commit da30bc1

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

packages/main/src/DurationPicker.js

+17-7
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,11 @@ class DurationPicker extends UI5Element {
318318
currentSeconds = this.getSecondsFromFormattedValue(destructuredValues); // this.hideHours && this.hideHours ? destructuredValues[0] : {};
319319

320320
if (currentHours > -1) {
321-
if (currentHours > this._maxValue[0]) {
321+
if (parseInt(currentHours) > parseInt(this._maxValue[0])) {
322322
currentHours = this._maxValue[0];
323323
}
324324

325-
this.selectedHours = this._formatSelectedValue(currentHours, 23);
325+
this.selectedHours = this._formatSelectedValue(currentHours, parseInt(this.readFormattedValue(this.maxValue)));
326326
}
327327

328328
if (currentMinutes > -1) {
@@ -331,7 +331,7 @@ class DurationPicker extends UI5Element {
331331
}
332332
if (this._maxValue[0] && this.selectedHours === this._maxValue[0]) {
333333
currentMinutes = currentMinutes > this._maxValue[1] ? this._maxValue[1] : currentMinutes;
334-
} else if (currentMinutes > this._maxValue[1]) {
334+
} else if (parseInt(currentMinutes) > parseInt(this._maxValue[1])) {
335335
currentMinutes = this._maxValue[1];
336336
}
337337

@@ -344,15 +344,15 @@ class DurationPicker extends UI5Element {
344344
}
345345
if (this._maxValue[0] && this._maxValue[1] && this.selectedHours >= this._maxValue[0] && this.selectedSeconds >= this._maxValue[1]) {
346346
currentSeconds = currentSeconds > this._maxValue[2] ? this._maxValue[2] : currentSeconds;
347-
} else if (currentSeconds > this._maxValue[2]) {
347+
} else if (parseInt(currentSeconds) > parseInt(this._maxValue[2])) {
348348
currentSeconds = this._maxValue[2];
349349
}
350350

351351
this.selectedSeconds = this._formatSelectedValue(currentSeconds, 59);
352352
}
353353
}
354354

355-
_formatSelectedValue(currentValue, maximum) {
355+
_formatSelectedValue(currentValue, maximum = Infinity) {
356356
if (currentValue.length === 1) {
357357
return `0${currentValue}`;
358358
}
@@ -494,8 +494,18 @@ class DurationPicker extends UI5Element {
494494
}
495495

496496
get hoursArray() {
497-
const currentHours = parseInt(this.readFormattedValue(this.maxValue)[0]);
498-
const hours = currentHours && currentHours > 0 && currentHours < 23 ? currentHours + 1 : 24;
497+
const _maxHours = parseInt(this.readFormattedValue(this.maxValue)[0]);
498+
const _currHours = parseInt(this.selectedHours) + 1;
499+
let hours;
500+
501+
if (_maxHours) {
502+
hours = _maxHours + 1;
503+
} else if (_currHours < 24) {
504+
hours = 24;
505+
} else {
506+
hours = _currHours;
507+
}
508+
499509
return this.generateTimeItemsArray(hours);
500510
}
501511

0 commit comments

Comments
 (0)