Skip to content

this.platform.is('tablet') not working properly #15434

Closed

Description

@smxdevst

Bug Report

Ionic:

   ionic (Ionic CLI)  : 4.1.1 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.11

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0, ios 4.5.5
   Cordova Plugins       : cordova-plugin-ionic-webview 1.2.1, (and 25 other plugins)

System:

   ios-deploy : 1.9.2
   NodeJS     : v8.9.4 (/usr/local/bin/node)
   npm        : 6.0.1
   OS         : macOS High Sierra
   Xcode      : Xcode 9.4.1 Build version 9F2000

Describe the Bug
On my phone Google Pixel 2 XL this.platform.is('tablet') giving true

Steps to Reproduce
Add this.platform.is('tablet') on any page on Google Pixel 2 XL

Expected Behavior
this.platform.is('tablet') should return false.

Activity

  1. yuankunluo commented on Sep 2, 2018

    @yuankunluo

    The platforms are: Android,iOS, windows, browser, windowsphone

  2. added
    type: feature request
    on Dec 7, 2018
  3. daem0ndev commented on Jan 19, 2019

    @daem0ndev
    Contributor

    @smxdevst in looking at the source its simply because the check for tablet is just checking to see if the viewport size is within a certain range:

    function isTablet(win: Window) {
      const width = win.innerWidth;
      const height = win.innerHeight;
      const smallest = Math.min(width, height);
      const largest = Math.max(width, height);
      return (smallest > 460 && smallest < 820) &&
        (largest > 780 && largest < 1400);
    }
    

    source: https://github.com/ionic-team/ionic/blob/master/core/src/utils/platform.ts#L70-L77

    This is at best just a good guess and therefor not 100% reliable. I would suggest to use other methods in addition to make your detection code a bit more full proof, for example user agent checks or modernizr.

    I had a similar issue where iPad Pro 12.9" was returning false for platform.is('tablet') because its so large in res it was showing as a desktop so I beefed up my check to also check with platform.is('ipad') etc.

  4. added
    package: core
    type: bug
    and removed
    type: feature request
    on Feb 27, 2019
  5. self-assigned this
    on Feb 27, 2019
  6. liamdebeasi commented on Mar 15, 2019

    @liamdebeasi
    Contributor

    Hi there,

    This issue has been resolved via #17630 and will be in the next release of Ionic.

    Thanks for the issue!

  7. ionitron-bot commented on Apr 14, 2019

    @ionitron-bot

    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.

  8. locked and limited conversation to collaborators on Apr 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

package: coretype: bug

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions