From 9f8ea8bb340585862972ed5942c3e36430b6f179 Mon Sep 17 00:00:00 2001 From: Reid Barber Date: Thu, 19 Nov 2026 21:41:02 -0600 Subject: [PATCH 1/2] fix(react-aria): preserve iPhone and iPad detection with iOS client hints --- packages/react-aria/src/utils/platform.ts | 10 ++++-- .../react-aria/test/utils/platform.test.ts | 32 +++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 packages/react-aria/test/utils/platform.test.ts diff --git a/packages/react-aria/src/utils/platform.ts b/packages/react-aria/src/utils/platform.ts index f0d91b0824f..d671a5d6d6a 100644 --- a/packages/react-aria/src/utils/platform.ts +++ b/packages/react-aria/src/utils/platform.ts @@ -23,9 +23,13 @@ function testUserAgent(re: RegExp) { } function testPlatform(re: RegExp) { - return typeof window !== 'undefined' && window.navigator != null - ? re.test(window.navigator['userAgentData']?.platform || window.navigator.platform) - : false; + if (typeof window === 'undefined' || window.navigator == null) { + return false; + } + + let platform = window.navigator['userAgentData']?.platform; + // The iOS platform hint is shared by iPhone and iPad. + return re.test(platform && platform !== 'iOS' ? platform : window.navigator.platform); } function cached(fn: () => boolean) { diff --git a/packages/react-aria/test/utils/platform.test.ts b/packages/react-aria/test/utils/platform.test.ts new file mode 100644 index 00000000000..69221cc8296 --- /dev/null +++ b/packages/react-aria/test/utils/platform.test.ts @@ -0,0 +1,32 @@ +/* + * Copyright 2026 Adobe. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ + +import {isAppleDevice, isIOS, isIPad, isIPhone} from '../../src/utils/platform'; + +describe('platform detection', function () { + afterEach(() => { + Reflect.deleteProperty(navigator, 'userAgentData'); + }); + + it.each(['iPhone', 'iPad'])('detects %s with an iOS platform hint', platform => { + using _platform = jest.spyOn(navigator, 'platform', 'get').mockReturnValue(platform); + Object.defineProperty(navigator, 'userAgentData', { + configurable: true, + value: {platform: 'iOS'} + }); + + expect(isIPhone()).toBe(platform === 'iPhone'); + expect(isIPad()).toBe(platform === 'iPad'); + expect(isIOS()).toBe(true); + expect(isAppleDevice()).toBe(true); + }); +}); From a6e05d39691adce38282d74d61e439f51ea67bf1 Mon Sep 17 00:00:00 2001 From: Reid Barber Date: Thu, 19 Nov 2026 21:51:44 -0600 Subject: [PATCH 2/2] fix lint --- packages/react-aria/test/utils/platform.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-aria/test/utils/platform.test.ts b/packages/react-aria/test/utils/platform.test.ts index 69221cc8296..368c3c12327 100644 --- a/packages/react-aria/test/utils/platform.test.ts +++ b/packages/react-aria/test/utils/platform.test.ts @@ -14,11 +14,12 @@ import {isAppleDevice, isIOS, isIPad, isIPhone} from '../../src/utils/platform'; describe('platform detection', function () { afterEach(() => { + jest.restoreAllMocks(); Reflect.deleteProperty(navigator, 'userAgentData'); }); it.each(['iPhone', 'iPad'])('detects %s with an iOS platform hint', platform => { - using _platform = jest.spyOn(navigator, 'platform', 'get').mockReturnValue(platform); + jest.spyOn(navigator, 'platform', 'get').mockReturnValue(platform); Object.defineProperty(navigator, 'userAgentData', { configurable: true, value: {platform: 'iOS'}