Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Switch): In the Android environment, the switch component button is on the right #47407

Open
nianxiongdi opened this issue Nov 5, 2024 · 9 comments
Labels
Component: Switch Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Needs: Attention Issues where the author has responded to feedback. Platform: Android Android applications.

Comments

@nianxiongdi
Copy link
Contributor

nianxiongdi commented Nov 5, 2024

Description

In the Android environment, the switch component button is on the right

Steps to reproduce

<SafeAreaView >
      <Switch />
</SafeAreaView>

android effect:
image

React Native Version

0.75.2

Affected Platforms

Runtime - Android

Output of npx react-native info

System:
  OS: macOS 14.5
  CPU: (12) arm64 Apple M3 Pro
  Memory: 118.28 MB / 18.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.11.0
    path: ~/.nvm/versions/node/v20.11.0/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v20.11.0/bin/yarn
  npm:
    version: 10.2.4
    path: ~/.nvm/versions/node/v20.11.0/bin/npm
  Watchman:
    version: 2024.08.26.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2412.12266719
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 15.0.0
    wanted: ^15.0.0
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.75.2
    wanted: ^0.75.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: false
  newArchEnabled: false

Stacktrace or Logs

none

Reproducer

none

Screenshots and Videos

No response

@react-native-bot
Copy link
Collaborator

⚠️ Newer Version of React Native is Available!
ℹ️ You are on a supported minor version, but it looks like there's a newer patch available - 0.75.4. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@react-native-bot react-native-bot added Newer Patch Available Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Nov 5, 2024
@react-native-bot
Copy link
Collaborator

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.

@react-native-bot
Copy link
Collaborator

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:

@react-native-bot
Copy link
Collaborator

⚠️ Newer Version of React Native is Available!
ℹ️ You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@shubhamguptadream11
Copy link
Collaborator

@nianxiongdi Is this behaviour changed with respect to some other version?

@shubhamguptadream11 shubhamguptadream11 added Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. and removed Component: Button Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Newer Patch Available labels Nov 5, 2024
@nianxiongdi
Copy link
Contributor Author

@shubhamguptadream11 nothing has changed.

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Nov 5, 2024
@nianxiongdi
Copy link
Contributor Author

@shubhamguptadream11 sow to solve it?

@cortinico
Copy link
Contributor

I quickly looked into this and I believe the Switch has always been positioned on the right (that's due to how Switch gravity behaves on Android natively). Not sure we're going to change this as it will be a breaking change for all the Switch users

@NickGerleman
Copy link
Contributor

NickGerleman commented Nov 8, 2024

View defaults to column with alignItems: stretch. That gives the switch the full width of the column. If you want it to stick to the left, try changing that to “start”, or place it in a row container, which I’m guessing most real layouts would do anyways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Switch Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Needs: Attention Issues where the author has responded to feedback. Platform: Android Android applications.
Projects
None yet
Development

No branches or pull requests

5 participants