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 button does not response #43976

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Changes from 1 commit
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
10 changes: 8 additions & 2 deletions src/pages/home/report/ReportActionCompose/SendButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Tooltip from '@components/Tooltip';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import CONST from '@src/CONST';

type SendButtonProps = {
Expand All @@ -22,7 +23,7 @@ function SendButton({isDisabled: isDisabledProp, handleSendMessage}: SendButtonP
const theme = useTheme();
const styles = useThemeStyles();
const {translate} = useLocalize();

const {isSmallScreenWidth} = useWindowDimensions();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const {isSmallScreenWidth} = useWindowDimensions();
const {isSmallScreenWidth} = useResponsiveLayout();

Please use isSmallScreenWidth from useResponsiveLayout

const Tap = Gesture.Tap().onEnd(() => {
handleSendMessage();
});
Expand All @@ -33,7 +34,12 @@ function SendButton({isDisabled: isDisabledProp, handleSendMessage}: SendButtonP
// Keep focus on the composer when Send message is clicked.
onMouseDown={(e) => e.preventDefault()}
>
<GestureDetector gesture={Tap}>
<GestureDetector
// A new GestureDetector instance must be created when switching from a large screen to a small screen
// if not, the GestureDetector may not function correctly.
key={`${isSmallScreenWidth ? 0 : 1}`}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it better if we name the key? send-button-${isSmallScreenWidth ? 'small-screen' : 'normal-screen'}

gesture={Tap}
>
<Tooltip text={translate('common.send')}>
<PressableWithFeedback
style={({pressed, isDisabled}) => [
Expand Down
Loading