fix(tauri): keep desktop message menus as popouts

This commit is contained in:
Erwan Leboucher authored and 7w1 committed 2026-08-08 21:33:00 -05:00
1 parent 3196728c94
commit 6cb29628df
2 files changed
+22 -1

No files matched your search

+21 -1
View File
@@ -1,6 +1,7 @@
import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest';
import { getAppOrigin, getWindowOrigin } from './platform';
import { getAppOrigin, getWindowOrigin, isMobileOrTablet, ua } from './platform';
import { isTauri } from '@tauri-apps/api/core';
import { type as osType } from '@tauri-apps/plugin-os';
vi.mock('@tauri-apps/api/core', () => ({
isTauri: vi.fn<() => boolean>(),
@@ -45,6 +46,25 @@ describe('getAppOrigin', () => {
});
});
describe('isMobileOrTablet', () => {
const originalDeviceType = ua.device.type;
const originalOsName = ua.os.name;
afterEach(() => {
ua.device.type = originalDeviceType;
ua.os.name = originalOsName;
});
it('uses the desktop Tauri OS instead of a mobile-looking WebView user agent', () => {
vi.mocked(isTauri).mockReturnValue(true);
vi.mocked(osType).mockReturnValue('windows');
ua.device.type = 'mobile';
ua.os.name = 'Android';
expect(isMobileOrTablet()).toBe(false);
});
});
describe('getWindowOrigin', () => {
afterEach(() => {
vi.unstubAllGlobals();
+1
View File
@@ -27,6 +27,7 @@ const DESKTOP_TAURI_OS = ['linux', 'macos', 'windows'] as const;
export function isMobileOrTablet(): boolean {
const tauriOS = getTauriOS();
if (tauriOS && (MOBILE_TAURI_OS as readonly string[]).includes(tauriOS)) return true;
if (tauriOS && (DESKTOP_TAURI_OS as readonly string[]).includes(tauriOS)) return false;
const { os, device } = ua;
if (device.type === 'mobile' || device.type === 'tablet') return true;