Skip to content

Commit

Permalink
Merge pull request #28240 from akinwale/task-28047
Browse files Browse the repository at this point in the history
fix: send message - user navigates to Room tab when dragging to select e-mail from Chat tab
  • Loading branch information
puneetlath authored Oct 3, 2023
2 parents 5fc9d9c + 37555f7 commit 18e051a
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 8 deletions.
9 changes: 2 additions & 7 deletions src/components/MapView/responder/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import {PanResponder} from 'react-native';
import SwipeInterceptPanResponder from '../../SwipeInterceptPanResponder';

const responder = PanResponder.create({
onMoveShouldSetPanResponder: () => true,
onPanResponderTerminationRequest: () => false,
});

export default responder;
export default SwipeInterceptPanResponder;
1 change: 1 addition & 0 deletions src/components/OptionsSelector/BaseOptionsSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ class BaseOptionsSelector extends Component {
selectTextOnFocus
blurOnSubmit={Boolean(this.state.allOptions.length)}
spellCheck={false}
shouldInterceptSwipe={this.props.shouldTextInputInterceptSwipe}
/>
);
const optionsList = (
Expand Down
1 change: 1 addition & 0 deletions src/components/OptionsSelector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const OptionsSelector = forwardRef((props, ref) => (
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
ref={ref}
shouldTextInputInterceptSwipe
/>
));

Expand Down
4 changes: 4 additions & 0 deletions src/components/OptionsSelector/optionsSelectorPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ const propTypes = {

/** Initial focused index value */
initialFocusedIndex: PropTypes.number,

/** Whether the text input should intercept swipes or not */
shouldTextInputInterceptSwipe: PropTypes.bool,
};

const defaultProps = {
Expand Down Expand Up @@ -160,6 +163,7 @@ const defaultProps = {
shouldUseStyleForChildren: true,
isRowMultilineSupported: false,
initialFocusedIndex: undefined,
shouldTextInputInterceptSwipe: false,
};

export {propTypes, defaultProps};
1 change: 1 addition & 0 deletions src/components/RoomNameInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function RoomNameInput({isFocused, autoFocus, disabled, errorText, forwardedRef,
autoFocus={isFocused && autoFocus}
maxLength={CONST.REPORT.MAX_ROOM_NAME_LENGTH}
spellCheck={false}
shouldInterceptSwipe
/>
);
}
Expand Down
8 changes: 8 additions & 0 deletions src/components/SwipeInterceptPanResponder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {PanResponder} from 'react-native';

const SwipeInterceptPanResponder = PanResponder.create({
onMoveShouldSetPanResponder: () => true,
onPanResponderTerminationRequest: () => false,
});

export default SwipeInterceptPanResponder;
7 changes: 6 additions & 1 deletion src/components/TextInput/BaseTextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import PressableWithoutFeedback from '../Pressable/PressableWithoutFeedback';
import withLocalize from '../withLocalize';
import useNativeDriver from '../../libs/useNativeDriver';
import * as Browser from '../../libs/Browser';
import SwipeInterceptPanResponder from '../SwipeInterceptPanResponder';

function BaseTextInput(props) {
const initialValue = props.value || props.defaultValue || '';
Expand Down Expand Up @@ -256,7 +257,11 @@ function BaseTextInput(props) {

return (
<>
<View style={styles.pointerEventsNone}>
<View
style={styles.pointerEventsNone}
// eslint-disable-next-line react/jsx-props-no-spreading
{...(props.shouldInterceptSwipe && SwipeInterceptPanResponder.panHandlers)}
>
<PressableWithoutFeedback
onPress={onPress}
focusable={false}
Expand Down
4 changes: 4 additions & 0 deletions src/components/TextInput/baseTextInputPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ const propTypes = {

/** Set the default value to the input if there is a valid saved value */
shouldUseDefaultValue: PropTypes.bool,

/** Indicate whether or not the input should prevent swipe actions in tabs */
shouldInterceptSwipe: PropTypes.bool,
};

const defaultProps = {
Expand Down Expand Up @@ -129,6 +132,7 @@ const defaultProps = {
icon: null,
shouldUseDefaultValue: false,
multiline: false,
shouldInterceptSwipe: false,
};

export {propTypes, defaultProps};

0 comments on commit 18e051a

Please sign in to comment.