Composer: Support triple click to select all (#1963)
This commit is contained in:
parent
72d46c6911
commit
31834d56b5
@ -58,6 +58,8 @@ type StateProps = {
|
|||||||
|
|
||||||
const MAX_INPUT_HEIGHT = IS_SINGLE_COLUMN_LAYOUT ? 256 : 416;
|
const MAX_INPUT_HEIGHT = IS_SINGLE_COLUMN_LAYOUT ? 256 : 416;
|
||||||
const TAB_INDEX_PRIORITY_TIMEOUT = 2000;
|
const TAB_INDEX_PRIORITY_TIMEOUT = 2000;
|
||||||
|
// Heuristics allowing the user to make a triple click
|
||||||
|
const SELECTION_RECALCULATE_DELAY_MS = 260;
|
||||||
const TEXT_FORMATTER_SAFE_AREA_PX = 90;
|
const TEXT_FORMATTER_SAFE_AREA_PX = 90;
|
||||||
// For some reason Safari inserts `<br>` after user removes text from input
|
// For some reason Safari inserts `<br>` after user removes text from input
|
||||||
const SAFARI_BR = '<br>';
|
const SAFARI_BR = '<br>';
|
||||||
@ -103,6 +105,8 @@ const MessageInput: FC<OwnProps & StateProps> = ({
|
|||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const inputRef = useRef<HTMLDivElement>(null);
|
const inputRef = useRef<HTMLDivElement>(null);
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
|
const selectionTimeoutRef = useRef<number>(null);
|
||||||
|
// eslint-disable-next-line no-null/no-null
|
||||||
const cloneRef = useRef<HTMLDivElement>(null);
|
const cloneRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
@ -207,8 +211,11 @@ const MessageInput: FC<OwnProps & StateProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function processSelectionWithTimeout() {
|
function processSelectionWithTimeout() {
|
||||||
|
if (selectionTimeoutRef.current) {
|
||||||
|
window.clearTimeout(selectionTimeoutRef.current);
|
||||||
|
}
|
||||||
// Small delay to allow browser properly recalculate selection
|
// Small delay to allow browser properly recalculate selection
|
||||||
setTimeout(processSelection, 1);
|
selectionTimeoutRef.current = window.setTimeout(processSelection, SELECTION_RECALCULATE_DELAY_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleMouseDown(e: React.MouseEvent<HTMLDivElement, MouseEvent>) {
|
function handleMouseDown(e: React.MouseEvent<HTMLDivElement, MouseEvent>) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user