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 [isTextFormatterOpen, openTextFormatter, closeTextFormatter] = useFlag();
|
||||||
const [textFormatterAnchorPosition, setTextFormatterAnchorPosition] = useState<IAnchorPosition>();
|
const [textFormatterAnchorPosition, setTextFormatterAnchorPosition] = useState<IAnchorPosition>();
|
||||||
const [selectedRange, setSelectedRange] = useState<Range>();
|
const [selectedRange, setSelectedRange] = useState<Range>();
|
||||||
|
const [isTextFormatterDisabled, setIsTextFormatterDisabled] = useState<boolean>(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isAttachmentModalInput) return;
|
if (!isAttachmentModalInput) return;
|
||||||
@ -161,6 +162,9 @@ const MessageInput: FC<OwnProps & StateProps> = ({
|
|||||||
const selection = window.getSelection();
|
const selection = window.getSelection();
|
||||||
if (!selection || !selection.rangeCount || isContextMenuOpenRef.current) {
|
if (!selection || !selection.rangeCount || isContextMenuOpenRef.current) {
|
||||||
closeTextFormatter();
|
closeTextFormatter();
|
||||||
|
if (IS_ANDROID) {
|
||||||
|
setIsTextFormatterDisabled(false);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,6 +189,10 @@ const MessageInput: FC<OwnProps & StateProps> = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isTextFormatterDisabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const selectionRange = window.getSelection()!.getRangeAt(0);
|
const selectionRange = window.getSelection()!.getRangeAt(0);
|
||||||
const selectionRect = selectionRange.getBoundingClientRect();
|
const selectionRect = selectionRange.getBoundingClientRect();
|
||||||
const inputRect = inputRef.current!.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()) {
|
if (!checkSelection()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
e.preventDefault();
|
setIsTextFormatterDisabled(!isTextFormatterDisabled);
|
||||||
e.stopPropagation();
|
|
||||||
|
if (!isTextFormatterDisabled) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
processSelection();
|
||||||
|
} else {
|
||||||
|
closeTextFormatter();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateInputHeight(willSend = false) {
|
function updateInputHeight(willSend = false) {
|
||||||
@ -396,7 +412,7 @@ const MessageInput: FC<OwnProps & StateProps> = ({
|
|||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
onMouseDown={handleMouseDown}
|
onMouseDown={handleMouseDown}
|
||||||
onContextMenu={IS_ANDROID ? stopEvent : undefined}
|
onContextMenu={IS_ANDROID ? handleAndroidContextMenu : undefined}
|
||||||
onTouchCancel={IS_ANDROID ? processSelectionWithTimeout : undefined}
|
onTouchCancel={IS_ANDROID ? processSelectionWithTimeout : undefined}
|
||||||
aria-label={placeholder}
|
aria-label={placeholder}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user