Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: send message - user navigates to Room tab when dragging to select e-mail from Chat tab #28240

Merged
merged 4 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -364,6 +364,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 inputValue = props.value || props.defaultValue || '';
Expand Down Expand Up @@ -257,7 +258,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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hii @akinwale @mollfpr, coming from this issue, do you guys think we can make default value of shouldInterceptSwipe as true for inputs? Since we would never swippable inputs I guess. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Krishna2323 Just caught up on this. The default can be set to true but you have to check to make sure that text selection still works as expected especially on Android and iOS native platforms.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks a lot :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Krishna2323 This is why it was set to false in the first place: #28240 (comment)

You would need to test on a physical Samsung device.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I guess its safe to fix only this instance. We are only using tab navigator in 2 places.

};

export {propTypes, defaultProps};
Loading