Attachment Modal: Disable input field autofocus on mobile (#3117)

This commit is contained in:
Alexander Zinchuk 2023-05-02 15:23:19 +04:00
parent 0a5cded695
commit 6781b496c7
2 changed files with 12 additions and 0 deletions

View File

@ -28,6 +28,7 @@ import { selectCurrentLimit } from '../../../global/selectors/limits';
import { openSystemFilesDialog } from '../../../util/systemFilesDialog';
import buildClassName from '../../../util/buildClassName';
import { validateFiles } from '../../../util/files';
import { removeAllSelections } from '../../../util/selection';
import usePrevious from '../../../hooks/usePrevious';
import useMentionTooltip from './hooks/useMentionTooltip';
@ -239,6 +240,12 @@ const AttachmentModal: FC<OwnProps & StateProps> = ({
}
}, [attachmentSettings, isOpen, shouldSuggestCompression]);
useEffect(() => {
if (isOpen && isMobile) {
removeAllSelections();
}
}, [isMobile, isOpen]);
const {
isContextMenuOpen: isCustomSendMenuOpen,
handleContextMenu,

View File

@ -92,3 +92,8 @@ export function setCaretPosition(element: Node, position: number) {
return position;
}
export function removeAllSelections() {
const selection = window.getSelection();
selection?.removeAllRanges();
}