This commit resolves the issue with the `:active` pseudo-class not
activating in mobile Safari on iOS devices. It introduces a workaround
specifically for mobile Safari on iOS/iPadOS to enable the `:active`
pseudo-class. This ensures a consistent and responsive user interface
in response to touch states on mobile Safari.
Other supporting changes:
- Introduce new test utility functions such as `createWindowEventSpies`
and `formatAssertionMessage` to improve code reusability and
maintainability.
- Improve browser detection:
- Add detection for iPadOS and Windows 10 Mobile.
- Add touch support detection to correctly determine iPadOS vs macOS.
- Fix misidentification of some Windows 10 Mobile platforms as Windows
Phone.
- Improve test coverage and refactor tests.
38 lines
1.5 KiB
TypeScript
38 lines
1.5 KiB
TypeScript
import { OperatingSystem } from '@/domain/OperatingSystem';
|
|
|
|
enum TouchSupportState {
|
|
AlwaysSupported,
|
|
MayBeSupported,
|
|
NeverSupported,
|
|
}
|
|
|
|
const TouchSupportPerOperatingSystem: Record<OperatingSystem, TouchSupportState> = {
|
|
[OperatingSystem.Android]: TouchSupportState.AlwaysSupported,
|
|
[OperatingSystem.iOS]: TouchSupportState.AlwaysSupported,
|
|
[OperatingSystem.iPadOS]: TouchSupportState.AlwaysSupported,
|
|
[OperatingSystem.ChromeOS]: TouchSupportState.AlwaysSupported,
|
|
[OperatingSystem.KaiOS]: TouchSupportState.MayBeSupported,
|
|
[OperatingSystem.BlackBerry10]: TouchSupportState.AlwaysSupported,
|
|
[OperatingSystem.BlackBerryOS]: TouchSupportState.AlwaysSupported,
|
|
[OperatingSystem.BlackBerryTabletOS]: TouchSupportState.AlwaysSupported,
|
|
[OperatingSystem.WindowsPhone]: TouchSupportState.AlwaysSupported,
|
|
[OperatingSystem.Windows10Mobile]: TouchSupportState.AlwaysSupported,
|
|
[OperatingSystem.Windows]: TouchSupportState.MayBeSupported,
|
|
[OperatingSystem.Linux]: TouchSupportState.MayBeSupported,
|
|
[OperatingSystem.macOS]: TouchSupportState.NeverSupported, // Consider Touch Bar as a special case
|
|
};
|
|
|
|
export function determineTouchSupportOptions(os: OperatingSystem): boolean[] {
|
|
const state = TouchSupportPerOperatingSystem[os];
|
|
switch (state) {
|
|
case TouchSupportState.AlwaysSupported:
|
|
return [true];
|
|
case TouchSupportState.MayBeSupported:
|
|
return [true, false];
|
|
case TouchSupportState.NeverSupported:
|
|
return [false];
|
|
default:
|
|
throw new Error(`Unknown state: ${TouchSupportState[state]}`);
|
|
}
|
|
}
|