react-native-windows icon indicating copy to clipboard operation
react-native-windows copied to clipboard

Unusual focus order when using react-native-picker

Open kochie-aim opened this issue 5 years ago • 6 comments

Environment

Run the following in your terminal and copy the results here.

  1. npx react-native --version: 4.13.1

  2. npx react-native info: System: OS: Windows 10 10.0.19042 CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz Memory: 2.64 GB / 15.80 GB Binaries: Node: 10.15.0 - C:\Program Files\nodejs\node.EXE npm: 6.13.6 - C:\Repos\pay.pidl.sdk\tests\apps\pidl-react-native-windows\node_modules.bin\npm.CMD npmPackages: react: 16.13.1 => 16.13.1 react-native: 0.63.2 => 0.63.2 react-native-windows: 0.63.3 => 0.63.3 Installed UWP SDKs: 10.0.17763.0 10.0.18362.0

What device(s) are you targeting? Choose any from Desktop, Xbox, Hololens)

  • Target Device(s): Desktop, Xbox Which version of Visual Studio are you using? Specify Visual Studio 2017 or Visual Studio 2019
  • Visual Studio Version: 2019 Which build configuration are you running? Choose from Debug, DebugBundle, Release, ReleaseBundle
  • Build Configuration: Debug, Release -->

Steps To Reproduce

This is a standalone app using react-native-picker https://github.com/react-native-picker/picker

  1. Add a Text Input, Picker, and a TextInput like in the code example below.
  2. Launch the app, using a keyboard, hit "tab" and view the focus order of the elements

Expected Results

The focus order should be element 1, 2, 3 (TextInput, Picker, TextInput)

Actual Results

The focus order is 1, 3, 2 (TextInput, TextInput, Picker).

The focus order is as expected using the deprecated react-native picker. I recreated this in a snack (https://snack.expo.io/I8HK59Irg) and the focus order was as expected. It is only using a standalone app where the issue occurs.

Snack, code example, screenshot, or link to a repository:

Please provide a Snack (https://snack.expo.io/), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. `import * as React from 'react'; import { TextInput, View, } from 'react-native'; import { Picker } from "@react-native-picker/picker";

 export default function App() {
     return (
         <View>
             <TextInput style={{marginVertical: 8, backgroundColor: "grey"}} key={1}/>
             <Picker style={{marginVertical: 8, backgroundColor: "grey"}} key={2}/>
             <TextInput style={{marginVertical: 8, backgroundColor: "grey"}} key={3}/>
         </View>
     );
}`

kochie-aim avatar Dec 17 '20 18:12 kochie-aim

Many of our core react-native-windows contributors are taking some much needed vacation throughout December 2020. Thank you for being patient while we relax, recharge, and return to a normal responsiveness in January 2021. In the meantime feel free to continue to pose questions, open issues, and make feature requests - you just may not get a response right away.

ghost avatar Dec 17 '20 18:12 ghost

There was a fix made here in 0.64 related to TextInput and tab order, which may be what you're hitting here. An upgrade may fix it. @rectified95 is going to take a look to see what that fix looked like so we can recommend an action for you.

chrisglein avatar Jan 04 '21 19:01 chrisglein

@kochie-aim Your problem should go away with an upgrade to RNW 0.64. In order to confirm that without making the upgrade first, you can remove one line in this function:

XamlView TextInputViewManager::CreateViewCore(int64_t /*tag*/) {
  xaml::Controls::TextBox textBox;
  // Remove line below and recompile project.
  // textBox.TabIndex(0);
  return textBox;
}

Ref: https://github.com/microsoft/react-native-windows/pull/6320

rectified95 avatar Jan 04 '21 22:01 rectified95

Verified myself that it works on version 0.64. Closing the issue. cc @kochie-aim This is not a problem with the Picker, but the TextInput.

rectified95 avatar Jan 05 '21 17:01 rectified95

@chrisglein Do you think this is something we could backport to 0.63? It would be a breaking change, but I don't think anyone would rely on incorrect behavior in their apps..

rectified95 avatar Jan 05 '21 17:01 rectified95

@rectified95 Thanks for the code snippet!

kochie-aim avatar Jan 05 '21 17:01 kochie-aim