mskocik / svelecte

Flexible autocomplete/select component written in Svelte,

Home Page:https://svelecte.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Broken Mac Detection

pzcfg opened this issue · comments

commented

There are a number of places where this isIOS / iOS() function gets used, e.g. to switch between ctrlKey and metaKey in onKeyDown()

function onKeyDown(event) {
event = event.detail; // from dispatched event
if (creatable && delimiter.indexOf(event.key) > -1) {
$inputValue.length > 0 && onSelect(null, $inputValue); // prevent creating item with delimiter itself
event.preventDefault();
return;
}
const Tab = selectOnTab && $hasDropdownOpened && !event.shiftKey ? 'Tab' : 'No-tab';
let ctrlKey = isIOS ? event.metaKey : event.ctrlKey;
let isPageEvent = ['PageUp', 'PageDown'].includes(event.key);
switch (event.key) {

And the comment above it says "Detect Mac device"…

/**
* Detect Mac device
*
* @returns {bool}
*/
export function iOS() {
return [
'iPad Simulator',
'iPhone Simulator',
'iPod Simulator',
'iPad',
'iPhone',
'iPod'
].includes(navigator.platform)
// iPad on iOS 13 detection
|| (navigator.userAgent.includes("Mac") && "ontouchend" in document)
}

…however, by having the && "ontouchend" in document this excludes desktop Mac devices.

I think this is causing some of the Mac behavior to only be triggered on iOS devices, not desktop Mac.

I'm not sure if there's functionality that needs to be conditionally changed for iOS vs macOS vs all Apple devices, but it seems like there may need to be some more specific / granular functions/conditions added to ensure these different cases aren't conflated.

Yes, this should be extended to all Mac as well.