diff --git a/webapp/channels/src/components/advanced_text_editor/advanced_text_editor.tsx b/webapp/channels/src/components/advanced_text_editor/advanced_text_editor.tsx index 27a635f3da..d080b50a0e 100644 --- a/webapp/channels/src/components/advanced_text_editor/advanced_text_editor.tsx +++ b/webapp/channels/src/components/advanced_text_editor/advanced_text_editor.tsx @@ -26,6 +26,7 @@ import MessageSubmitError from 'components/message_submit_error'; import MsgTyping from 'components/msg_typing'; import OverlayTrigger from 'components/overlay_trigger'; import RhsSuggestionList from 'components/suggestion/rhs_suggestion_list'; +import SuggestionList from 'components/suggestion/suggestion_list'; import Textbox from 'components/textbox'; import type {TextboxElement} from 'components/textbox'; import type TextboxClass from 'components/textbox/textbox'; @@ -684,7 +685,7 @@ const AdvanceTextEditor = ({ {labels} & { export default function RhsSuggestionList(props: Props): JSX.Element { const [position, setPosition] = useState('top'); + const isMobile = useSelector(getIsMobileView); useEffect(() => { const input = props.inputRef.current; - if (input && props.open) { const inputTop = input.getBoundingClientRect().top ?? 0; - const newPosition = (inputTop < Constants.SUGGESTION_LIST_SPACE_RHS) ? 'bottom' : 'top'; + const requiredSpace = isMobile ? Constants.MOBILE_SUGGESTION_LIST_SPACE_RHS : Constants.SUGGESTION_LIST_SPACE_RHS; + const newPosition = (inputTop < requiredSpace) ? 'bottom' : 'top'; if (newPosition !== position) { // This potentially causes a second render when the list position changes, but that's better @@ -28,7 +32,7 @@ export default function RhsSuggestionList(props: Props): JSX.Element { setPosition(newPosition); } } - }, [position, props.inputRef, props.open]); + }, [position, props.inputRef, props.open, isMobile]); return (