From de1ab0113ab01d3e5d3ffdf46867af12386f0ebb Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Sat, 28 Sep 2024 16:53:51 +0700 Subject: [PATCH] fix isMobile --- packages/graz/src/utils/os.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/graz/src/utils/os.ts b/packages/graz/src/utils/os.ts index 2a359e36..c5c68260 100644 --- a/packages/graz/src/utils/os.ts +++ b/packages/graz/src/utils/os.ts @@ -1,9 +1,17 @@ export const isMobile = () => { if (typeof window !== "undefined") { - return Boolean( - window.matchMedia("(pointer:coarse)").matches || - /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent), - ); + const userAgent = navigator.userAgent; + + // Check for common mobile devices by examining user agent strings + if (/android/i.test(userAgent)) { + return true; + } + + if (/iPad|iPhone|iPod/.test(userAgent)) { + return true; + } + + return false; } return false;