ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
51.07k stars 13.51k forks source link

bug: Platfrom.isMobile return true even in Desktop in some cases #18388

Closed almothafar closed 5 years ago

almothafar commented 5 years ago

Bug Report

Ionic version: [x] 4.x

Current behavior: I use the ionic project as a web and mobile app, so I have to handle big screens and desktop version using Platforms when I open the website in some devices, especially remotely, I get everything messed up, because it is got the mobile version running on the desktop one, after 3 days of troubleshooting, I found that the issues related to Ionic, as first I thought it could be cleint-side only issues.

Currently, I get the classes plt-mobile plt-mobileweb applied to the <html> tag, and calling window.Ionic.platfroms returns with mobile and mobileweb:

image

Expected behavior: The desktop should be desktop, and detect the device correctly, as what they do in all website in the world and this http://detectmobilebrowsers.com/

Steps to reproduce: I can't provide the correct way, as it depends on some clients, but I found that I can get the issue if I open the website using remote desktop, I'm not sure how to reproduce it, in work machines everything is fine, on my home machine, and client machine, the issues happen.

Related code: I think this is related to this part for code: https://github.com/ionic-team/ionic/blob/master/core/src/utils/platform.ts#L68

It is totally wrong, see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/any-pointer

Ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.12.0 (C:\Users\almothafar\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.4.0
   @angular-devkit/build-angular : 0.13.9
   @angular-devkit/schematics    : 7.3.9
   @angular/cli                  : 7.3.9
   @ionic/angular-toolkit        : 1.5.1

Capacitor:

   capacitor (Capacitor CLI) : not installed
   @capacitor/core           : not installed

Cordova:

   cordova (Cordova CLI) : 9.0.0
   Cordova Platforms     : not available
   Cordova Plugins       : not available

System:

   Android SDK Tools : 26.1.1 (D:\Android\sdk)
   NodeJS            : v12.3.0 (C:\Program Files\nodejs\node.exe)
   npm               : 6.9.0
   OS                : Windows 10
liamdebeasi commented 5 years ago

Hi there,

Thanks for the issue! I am going to close this since this is a known issue.

Fixing this would require breaking changes, so I created a feature request here: https://github.com/ionic-team/ionic/issues/17631.

Thanks for using Ionic!

almothafar commented 5 years ago

@liamdebeasi but if this is an issue, then you should fix it or provide some other API that returns with the correct result, adding different classes!

liamdebeasi commented 5 years ago

Hi there,

Like I mentioned previously, properly fixing this would require breaking changes, and we only do breaking changes with major releases (4.0, 5.0, 6.0, etc). The feature request I created is something that will be considered for the next major release of Ionic.

We aren't ignoring your issue, I am just letting you know that since it requires a breaking change we can't implement a fix right at this moment 🙂

Thanks!

ionitron-bot[bot] commented 5 years ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.