Skip to content
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;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The same things can be applied to MapView/responder/index.android.ts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The responder in MapView/responder/index.android.ts uses onStartShouldSetPanResponder, not onMoveShouldSetPanResponder, so that is different.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ohh I didn't see that 😅

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the point of this file if all it does is export another file. Do we need it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My reasoning here was to try to maintain the responder file structure since we have platform-specific implementations for web, iOS and Android. It's not "strictly" needed.

@akinwale akinwale Oct 2, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@puneetlath Looks like I lied. The TypeScript Checks job fails if there is no index.ts file present, so this is actually needed for now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok got it!

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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};