From 05a2bc37371f95987ccfafdef153cc138b2c5ae4 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Thu, 7 Apr 2022 04:06:57 +0800 Subject: [PATCH 01/52] draft --- Libraries/Components/Button.js | 5 +- .../Touchable/TouchableNativeFeedback.js | 10 +- .../js/examples/Button/ButtonExample.js | 213 ++++-------------- 3 files changed, 59 insertions(+), 169 deletions(-) diff --git a/Libraries/Components/Button.js b/Libraries/Components/Button.js index 89ec384fe2c1b7..1170e8766000f4 100644 --- a/Libraries/Components/Button.js +++ b/Libraries/Components/Button.js @@ -317,14 +317,15 @@ class Button extends React.Component { return ( { render(): React.Node { const element = React.Children.only(this.props.children); const children = [element.props.children]; + let title = ''; + // if !props.accessibilityLabel + React.Children.map(children, child => { + if (!child?.props?.accessible && !child?.props?.focusable) { + title += ', ' + child.props.children; + } + }); + console.log('TouchableNativeFeedback title', title); if (__DEV__) { if (element.type === View) { children.push( @@ -272,7 +280,7 @@ class TouchableNativeFeedback extends React.Component { accessible: this.props.accessible !== false, accessibilityHint: this.props.accessibilityHint, accessibilityLanguage: this.props.accessibilityLanguage, - accessibilityLabel: this.props.accessibilityLabel, + accessibilityLabel: title, accessibilityRole: this.props.accessibilityRole, accessibilityState: accessibilityState, accessibilityActions: this.props.accessibilityActions, diff --git a/packages/rn-tester/js/examples/Button/ButtonExample.js b/packages/rn-tester/js/examples/Button/ButtonExample.js index dd97ad5a78f414..e7be8a10f0b655 100644 --- a/packages/rn-tester/js/examples/Button/ButtonExample.js +++ b/packages/rn-tester/js/examples/Button/ButtonExample.js @@ -12,7 +12,15 @@ const React = require('react'); -const {Alert, Button, View, StyleSheet} = require('react-native'); +const { + Alert, + Button, + View, + StyleSheet, + Text, + Pressable, + TouchableNativeFeedback, +} = require('react-native'); const {RNTesterThemeContext} = require('../../components/RNTesterTheme'); function onButtonPress(buttonName) { @@ -26,180 +34,53 @@ exports.title = 'Button'; exports.documentationURL = 'https://reactnative.dev/docs/button'; exports.description = 'Simple React Native button component.'; +function TouchableExample(props) { + return ( + + + + Text number 1 + + + Text number 2 + + + + ); +} + exports.examples = [ { title: 'Button with default styling', render: function (): React.Node { return ( -