Message Input: Open system context menu on second tap (#2068)
This commit is contained in:
parent
8a55ebb650
commit
122ef3fc03
@ -112,6 +112,7 @@ const MessageInput: FC<OwnProps & StateProps> = ({
|
||||
const [isTextFormatterOpen, openTextFormatter, closeTextFormatter] = useFlag();
|
||||
const [textFormatterAnchorPosition, setTextFormatterAnchorPosition] = useState<IAnchorPosition>();
|
||||
const [selectedRange, setSelectedRange] = useState<Range>();
|
||||
const [isTextFormatterDisabled, setIsTextFormatterDisabled] = useState<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isAttachmentModalInput) return;
|
||||
@ -161,6 +162,9 @@ const MessageInput: FC<OwnProps & StateProps> = ({
|
||||
const selection = window.getSelection();
|
||||
if (!selection || !selection.rangeCount || isContextMenuOpenRef.current) {
|
||||
closeTextFormatter();
|
||||
if (IS_ANDROID) {
|
||||
setIsTextFormatterDisabled(false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -185,6 +189,10 @@ const MessageInput: FC<OwnProps & StateProps> = ({
|
||||
return;
|
||||
}
|
||||
|
||||
if (isTextFormatterDisabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const selectionRange = window.getSelection()!.getRangeAt(0);
|
||||
const selectionRect = selectionRange.getBoundingClientRect();
|
||||
const inputRect = inputRef.current!.getBoundingClientRect();
|
||||
@ -299,13 +307,21 @@ const MessageInput: FC<OwnProps & StateProps> = ({
|
||||
}
|
||||
}
|
||||
|
||||
function stopEvent(e: React.MouseEvent<HTMLDivElement, MouseEvent>) {
|
||||
function handleAndroidContextMenu(e: React.MouseEvent<HTMLDivElement, MouseEvent>) {
|
||||
if (!checkSelection()) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
setIsTextFormatterDisabled(!isTextFormatterDisabled);
|
||||
|
||||
if (!isTextFormatterDisabled) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
processSelection();
|
||||
} else {
|
||||
closeTextFormatter();
|
||||
}
|
||||
}
|
||||
|
||||
function updateInputHeight(willSend = false) {
|
||||
@ -396,7 +412,7 @@ const MessageInput: FC<OwnProps & StateProps> = ({
|
||||
onChange={handleChange}
|
||||
onKeyDown={handleKeyDown}
|
||||
onMouseDown={handleMouseDown}
|
||||
onContextMenu={IS_ANDROID ? stopEvent : undefined}
|
||||
onContextMenu={IS_ANDROID ? handleAndroidContextMenu : undefined}
|
||||
onTouchCancel={IS_ANDROID ? processSelectionWithTimeout : undefined}
|
||||
aria-label={placeholder}
|
||||
/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user