Skip to content

Commit 91d427f

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Fix Switch layout with iOS26 (#53326)
Summary: Pull Request resolved: #53326 Apple changed the sizes of the UISwitchComponent and now, if you build an iOs app using the <Switch> component, the layout of the app will be broken because of wrong layout measurements. This has been reported also by [https://github.com/facebook/react-native/issues/52823](https://github.com/facebook/react-native/issues/52823). The `<Switch>` component was using hardcoded values for its size. This change fixes the problem by: - Using codegen for interface only - Implementing a custom Sadow Node to ask the platform for the Switch measurements - Updating the JS layout to wrap the size around the native component. ## Changelog: [iOS][Fixed] - Fix Switch layout to work with iOS26 Reviewed By: sammy-SC Differential Revision: D80454350 fbshipit-source-id: 1d468910276f7fde4559d2ae87cf60c8494caceb
1 parent d28ee16 commit 91d427f

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

packages/react-native/Libraries/Components/Switch/Switch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ const Switch: component(
264264
disabled,
265265
onTintColor: trackColorForTrue,
266266
style: StyleSheet.compose(
267-
{height: 31, width: 51},
267+
{alignSelf: 'flex-start' as const},
268268
StyleSheet.compose(
269269
style,
270270
ios_backgroundColor == null

packages/react-native/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,5 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
5858
export default (codegenNativeComponent<SwitchNativeProps>('Switch', {
5959
paperComponentName: 'RCTSwitch',
6060
excludedPlatforms: ['android'],
61+
interfaceOnly: true,
6162
}): ComponentType);

0 commit comments

Comments
 (0)