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

Dialog shifts vertically multiple times when app is backgrounded then foregrounded. #151

Open
dchhetri opened this issue Dec 17, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@dchhetri
Copy link

dchhetri commented Dec 17, 2022

Environment

System:
OS: macOS 12.4
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 1.43 GB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
Watchman: 2022.02.07.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.8.4 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild
Languages:
Java: Not Found
npmPackages:
@react-native-community/cli: Not Found
react: 18.1.0 => 18.1.0
react-native: 0.70.5 => 0.70.5
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Platforms

Verified only on iOS

Versions

  • Android:
  • iOS: 16.2
  • react-native-dialog: 9.3.0
  • react-native: 0.70.5
  • react: 18.1.0

Description

The dialog renders with keyboardVerticalOffset vertical offset. I then background the app. Then foreground the app. I see the dialog now has shifted even more vertically than the original vertical offset.

It is worth noting that the shift happens only once. Multiple background then foreground doesn't continue to shift the dialog higher.

The full component code

const PromptDialog = (props: PromptDialogProps) => {
  const { title, description, placeholder, visible, onCancel, onSave } = props
  const [inputText, setInputText] = useState("")
  return (
    <Dialog.Container visible={visible} keyboardVerticalOffset={400}>
      <Dialog.Title>{title}</Dialog.Title>
      <Dialog.Description>{description}</Dialog.Description>
      <Dialog.Input
        placeholder={placeholder}
        value={inputText}
        onChangeText={setInputText}
        autoFocus={true}
      />
      <Dialog.Button label="Cancel" onPress={onCancel} />
      <Dialog.Button label="Save" onPress={() => onSave(inputText)} />
    </Dialog.Container>
  )
}

It causes the dialog to shift up even more after backgrounding then foregrounding. Demo below.

Reproducible Demo

RPReplay_Final1671255213.mp4
@dchhetri dchhetri added the bug Something isn't working label Dec 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant