Skip to content

Commit

Permalink
fix(ui5-timepicker): allow inputs popover on tablet (#9701)
Browse files Browse the repository at this point in the history
fixes: #9705
  • Loading branch information
tsanislavgatev authored Aug 20, 2024
1 parent 7ed8a88 commit 20fd09c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions packages/main/src/TimePicker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isPhone } from "@ui5/webcomponents-base/dist/Device.js";
import { isDesktop, isPhone, isTablet } from "@ui5/webcomponents-base/dist/Device.js";
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
Expand Down Expand Up @@ -422,6 +422,10 @@ class TimePicker extends UI5Element implements IFormInputElement {
return isPhone();
}

get _isMobileDevice() {
return !isDesktop() && (isPhone() || isTablet());
}

onTimeSelectionChange(e: CustomEvent<TimeSelectionChangeEventDetail>) {
this.tempValue = e.detail.value; // every time the user changes the time selection -> update tempValue
}
Expand Down Expand Up @@ -503,7 +507,7 @@ class TimePicker extends UI5Element implements IFormInputElement {
return;
}

if (this._isPhone && target && !target.hasAttribute("ui5-icon")) {
if (this._isMobileDevice && target && !target.hasAttribute("ui5-icon")) {
this.toggleInputsPopover();
}

Expand Down Expand Up @@ -559,7 +563,7 @@ class TimePicker extends UI5Element implements IFormInputElement {
}

_canOpenInputsPopover() {
return !this.disabled && this._isPhone;
return !this.disabled && this._isMobileDevice;
}

_getPopover() {
Expand All @@ -580,7 +584,7 @@ class TimePicker extends UI5Element implements IFormInputElement {
}

_onkeydown(e: KeyboardEvent) {
if (this._isPhone && !this.isInputsPopoverOpen()) {
if (this._isMobileDevice && !this.isInputsPopoverOpen()) {
e.preventDefault();
}
if (isShow(e)) {
Expand Down Expand Up @@ -710,7 +714,7 @@ class TimePicker extends UI5Element implements IFormInputElement {
}

_onfocusin(e: FocusEvent) {
if (this._isPhone) {
if (this._isMobileDevice) {
this._hideMobileKeyboard();
if (this._isInputsPopoverOpen) {
const popover = this._getInputsPopover();
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/TimePickerPopover.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</div>
</ui5-responsive-popover>

{{#if _isPhone}}
{{#if _isMobileDevice}}
<ui5-popover
id="{{_id}}-popover"
class="ui5-time-picker-inputs-popover"
Expand Down

0 comments on commit 20fd09c

Please sign in to comment.