From 1d43c0202db9016d73ff1086ac3a24ac37abadec Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 28 Sep 2023 13:01:11 +0530 Subject: [PATCH 1/8] Allow bubbling Enter key press event on Button --- src/components/Button/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Button/index.js b/src/components/Button/index.js index 4ca933a45d6f..dc12a4ded5c2 100644 --- a/src/components/Button/index.js +++ b/src/components/Button/index.js @@ -18,6 +18,9 @@ import PressableWithFeedback from '../Pressable/PressableWithFeedback'; import refPropTypes from '../refPropTypes'; const propTypes = { + /** Should the press event bubble across multiple instances when Enter key triggers it. */ + allowBubble: PropTypes.bool, + /** The text for the button label */ text: PropTypes.string, @@ -123,6 +126,7 @@ const propTypes = { }; const defaultProps = { + allowBubble: false, text: '', shouldShowRightIcon: false, icon: null, @@ -183,7 +187,7 @@ class Button extends Component { shortcutConfig.descriptionKey, shortcutConfig.modifiers, true, - false, + this.props.allowBubble, this.props.enterKeyEventListenerPriority, false, ); From b93018d7d0a0362d146a7eb4097777551f2531df Mon Sep 17 00:00:00 2001 From: Rajat Parashar Date: Thu, 28 Sep 2023 13:24:48 +0530 Subject: [PATCH 2/8] Add story for bubbling effect --- src/stories/Button.stories.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/stories/Button.stories.js b/src/stories/Button.stories.js index 52212e673f0f..2c2ecb957eb2 100644 --- a/src/stories/Button.stories.js +++ b/src/stories/Button.stories.js @@ -1,5 +1,8 @@ +/* eslint-disable react/jsx-props-no-spreading */ import React, {useCallback, useState} from 'react'; +import {View} from 'react-native'; import Button from '../components/Button'; +import Text from '../components/Text'; /** * We use the Component Story Format for writing stories. Follow the docs here: @@ -28,7 +31,6 @@ function PressOnEnter(props) { }, []); return (