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

disabled TouchableHighlight still receives keyboard focus

Open AgneLukoseviciute opened this issue 2 years ago • 1 comments

Problem Description

from: https://github.com/microsoft/react-native-windows/issues/8781

Disabled TouchableHighlight still receives keyboard focus if onPress is defined.

Steps To Reproduce

  1. Set disabled={true} and define an onPress handler for a TouchableHighlight component
  2. tab through and observe how it still receives keyboard focus
  3. vs if you remove the onPress it behaves as expected and no longer gets keyboard focus

Expected Results

No response

CLI version

6.1.0

Environment

npx react-native info

Target Platform Version

No response

Target Device(s)

No response

Visual Studio Version

No response

Build Configuration

No response

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

      <View>
            <TouchableHighlight disabled={true} onPress={this._handlePress}>
              <Text>text within a disabled touchable</Text>
            </TouchableHighlight>
            <TouchableHighlight onPress={this._handlePress}>
              <Text>text within a disabled touchable</Text>
            </TouchableHighlight>
      </View>

The disabled TouchableHighlight still receives keyboard focus

AgneLukoseviciute avatar Oct 20 '21 23:10 AgneLukoseviciute

explicitly setting focusable to false can be used as a workaround. I think we'll want to do something similar to https://github.com/microsoft/react-native-windows/pull/9840 so that when the disabled prop is set to true, we make the control not focusable/inaccessible. This will mimic the behavior in XAML

AgneLukoseviciute avatar Aug 23 '22 22:08 AgneLukoseviciute