Skip to content

EspoCRM – Open Source CRM Application

Native select if mobile

Yuriif672cd57a91c
diff --git a/client/src/utils.ts b/client/src/utils.ts
index 78ccf4459d..afb9d7c1da 100644
--- a/client/src/utils.ts
+++ b/client/src/utils.ts
@@ -31,7 +31,7 @@ import type ViewHelper from 'view-helper';
import type AclManager from 'acl-manager';
import type Model from 'model';
import type User from 'models/user';
-import _ from 'underscore';
+import _, {functions} from 'underscore';
export interface AccessDefs {
/**
@@ -749,7 +749,21 @@ const Utils = {
}
return baseUrl;
- }
+ },
+
+ /**
+ * @since 10.1.0
+ * @internal
+ */
+ isMobile: function(): boolean {
+ if (!('userAgentData' in navigator)) {
+ return false;
+ }
+
+ const userAgentData = navigator.userAgentData as Record<string, any>;
+
+ return userAgentData.mobile ?? false;
+ },
};
const keyMap = {
diff --git a/client/src/views/fields/enum.ts b/client/src/views/fields/enum.ts
index 39111c4c35..daa0f59bf0 100644
--- a/client/src/views/fields/enum.ts
+++ b/client/src/views/fields/enum.ts
@@ -215,6 +215,10 @@ class EnumFieldView<
}
protected setup() {
+ if (Utils.isMobile()) {
+ this.nativeSelect = true;
+ }
+
if (!this.params.options) {
// @todo Revise.
const methodName = 'get' + Utils.upperCaseFirst(this.name) + 'Options';