Skip to content

[0.73] Add disabled property to props being passed into Pressable component - #12811

Merged
Yajur Grover (Yajur-Grover) merged 2 commits into
microsoft:0.73-stablefrom
Yajur-Grover:backport-b129040736b64001391b344f09d6469aeec668f1
Mar 8, 2024
Merged

Yajur Grover (Yajur-Grover) merged 2 commits into
microsoft:0.73-stablefrom
Yajur-Grover:backport-b129040736b64001391b344f09d6469aeec668f1

Conversation

@Yajur-Grover

@Yajur-Grover Yajur Grover (Yajur-Grover) commented Mar 7, 2024 •

Copy link
Copy Markdown
Contributor

Description

Backports #12799 into 0.73-stable.

Adds the value of the disabled property to props that are being passed into the Pressable component native code. Additionally, also adds a disabled property check before calling the onKeyDown event handler.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Why

Resolves microsoft/react-native-gallery#364
Resolves microsoft/react-native-gallery#363

What

Added statement to set Boolean value of prop before passed into Pressable component, and disabled property conditional check to onKeyDown handler.

Testing

Tested in RNTester and standalone example Pressable component.

Sample Pressable component code:

<Pressable
  accessibilityRole="button"
  accessibilityLabel={'example disabled pressable'}
  style={{
    width: 140,
    height: 50,
    borderRadius: 2,
    backgroundColor:'silver',
    opacity: 0.5,
  }}
  disabled={true}>
  {({pressed}) => (
    <Text
      style={{
        textAlign: 'center',
        paddingVertical: 15,
        color: 'black',
      }}>
      {pressed ? 'This will never be triggered.' : 'Disabled Pressable'}
    </Text>
  )}
</Pressable>

Changelog

Should this change be included in the release notes: yes

Microsoft Reviewers: Open in CodeFlow
@Yajur-Grover
Yajur Grover (Yajur-Grover) marked this pull request as ready for review March 7, 2024 21:29
@Yajur-Grover
Yajur Grover (Yajur-Grover) requested a review from a team as a code owner March 7, 2024 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants