My code is not working in mobile mode

I tried this in site code:

import wixWindow from ‘wix-window’;

$w.onReady( function () {
if (wixWindow.formFactor === “Desktop”){
console.log(“It’s Desktop”);
$w(“#quickSearchBar”).show();
$w(“#quickSearchButton”).show();
}
else {
console.log(“It’s Mobile”);
}
});

I hide #quickSearchBar and #quickSearchButton in Mobile mode. But when i run it in mobile mode, console still log: “It’s desktop” ? and raise error “TypeError: $w(…).show is not a function”. I want Wix skip that code in mobile mode but i don’t know how.
Please help me !!

Hi,

Your code is OK.
Due to a bug, ‘Desktop’ is returned back when calling formFactor while previewing in mobile mode.
We are already aware and working on a fix.

Note that it will not have any affect on your live site, your code should work fine on your published mobile site.

Hi,

It’s ok if it work fine on my published mobile site. Hope Wix fix this bug soon.
Thank for your supporting.