react-device-detect icon indicating copy to clipboard operation
react-device-detect copied to clipboard

BrowserView, MobileView, TabletView shows on iPad at the same time

Open artmsv opened this issue 3 years ago • 5 comments

  1. Bug description BrowserView, MobileView, TabletView shows on iPad at the same time
  2. Steps to reproduce Add BrowserView, MobileView, TabletView into react component, start iPad simulator on macOS, open page in safari
  3. Device user-agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15" I used this user-agent in desktop chrome and the issue is not appearing.
  4. Device/Browser type/name Safari on iPad simulator, iPad (8th generation), and all pro versions with ipadOS 14
  5. Share code for a better understanding (for example, here https://codesandbox.io/s/new) https://codesandbox.io/s/priceless-williamson-r8xug?file=/src/App.js
  6. Any additional info Screen Shot 2020-10-08 at 11 13 58 AM

artmsv avatar Oct 08 '20 18:10 artmsv

version of lib: v1.14.0

artmsv avatar Oct 09 '20 17:10 artmsv

Glad I'm not the only one. Is there any workaround that you know of at this moment @h3xsoul ?

I know this problem doesn't appear when using chrome on the ipad, but I need to handle the safari edge case as well.

matthew9510 avatar Oct 09 '20 19:10 matthew9510

@matthew9510 As you can see from the screenshot isTablet = true for tablets and false for mobile and desktops. So I used {!isTablet && <BrowserView/> } in this case it will show proper view on each platform

artmsv avatar Oct 13 '20 20:10 artmsv

@h3xsoul right on. Thanks

matthew9510 avatar Oct 13 '20 20:10 matthew9510

I fixed it by making my own BrowserView which I import instead of the original one

import React from 'react';
import {CustomView, isBrowser, isTablet} from "react-device-detect";

export default function BrowserView ({children, ...props}) {
    return (
        <CustomView condition={isBrowser && !isTablet} {...props}>
            {children}
        </CustomView>
    )
}

sinnbeck avatar Jan 11 '21 14:01 sinnbeck