Skip to content

Commit

Permalink
fix context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
christianwen committed Oct 5, 2024
1 parent 8595df0 commit 2cd4727
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 20 deletions.
8 changes: 1 addition & 7 deletions src/components/Composer/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function Composer(
selection,
value,
isGroupPolicyReport = false,
showSoftInputOnFocus = true,
...props
}: ComposerProps,
ref: ForwardedRef<TextInput>,
Expand All @@ -49,7 +50,6 @@ function Composer(
const markdownStyle = useMarkdownStyle(value, !isGroupPolicyReport ? excludeReportMentionStyle : excludeNoStyles);
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const [showSoftInputOnFocus, setShowSoftInputOnFocus] = useState(false);

const [contextMenuHidden, setContextMenuHidden] = useState(true);

Expand Down Expand Up @@ -150,12 +150,6 @@ function Composer(
onClear={onClear}
showSoftInputOnFocus={showSoftInputOnFocus}
contextMenuHidden={contextMenuHidden}
onTouchStart={() => {
if (showSoftInputOnFocus) {
return;
}
setShowSoftInputOnFocus(true);
}}
/>
);
}
Expand Down
14 changes: 1 addition & 13 deletions src/components/Composer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function Composer(
isComposerFullSize = false,
shouldContainScroll = true,
isGroupPolicyReport = false,
showSoftInputOnFocus = true,
...props
}: ComposerProps,
ref: ForwardedRef<TextInput | HTMLInputElement>,
Expand Down Expand Up @@ -103,7 +104,6 @@ function Composer(
const isScrollBarVisible = useIsScrollBarVisible(textInput, value ?? '');
const [prevScroll, setPrevScroll] = useState<number | undefined>();
const isReportFlatListScrolling = useRef(false);
const [showSoftInputOnFocus, setShowSoftInputOnFocus] = useState(false);

useEffect(() => {
if (!!selection && selectionProp.start === selection.start && selectionProp.end === selection.end) {
Expand Down Expand Up @@ -399,18 +399,6 @@ function Composer(
}}
disabled={isDisabled}
onKeyPress={handleKeyPress}
onTouchStart={() => {
if (showSoftInputOnFocus) {
return;
}
if (Browser.isMobileSafari()) {
setTimeout(() => {
setShowSoftInputOnFocus(true);
}, CONST.ANIMATED_TRANSITION);
return;
}
setShowSoftInputOnFocus(true);
}}
/>
{shouldCalculateCaretPosition && renderElementForCaretPosition}
</>
Expand Down
2 changes: 2 additions & 0 deletions src/components/Composer/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ type ComposerProps = Omit<TextInputProps, 'onClear'> & {

/** Indicates whether the composer is in a group policy report. Used for disabling report mentioning style in markdown input */
isGroupPolicyReport?: boolean;

showSoftInputOnFocus?: boolean;
};

export type {TextSelection, ComposerProps, CustomSelectionChangeEvent};
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ function ComposerWithSuggestions(

const [composerHeight, setComposerHeight] = useState(0);

const [showSoftInputOnFocus, setShowSoftInputOnFocus] = useState(false);

const textInputRef = useRef<TextInput | null>(null);

const syncSelectionWithOnChangeTextRef = useRef<SyncSelection | null>(null);
Expand Down Expand Up @@ -772,6 +774,19 @@ function ComposerWithSuggestions(
onScroll={hideSuggestionMenu}
shouldContainScroll={Browser.isMobileSafari()}
isGroupPolicyReport={isGroupPolicyReport}
showSoftInputOnFocus={showSoftInputOnFocus}
onTouchStart={() => {
if (showSoftInputOnFocus) {
return;
}
if (Browser.isMobileSafari()) {
setTimeout(() => {
setShowSoftInputOnFocus(true);
}, CONST.ANIMATED_TRANSITION);
return;
}
setShowSoftInputOnFocus(true);
}}
/>
</View>

Expand Down

0 comments on commit 2cd4727

Please sign in to comment.