CtrlBackspace fixed on Macbook (#765)

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-08-15 13:09:11 +00:00 committed by GitHub
commit 5140ae605d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -239,27 +239,18 @@ export function handleKeyDown(
inputValue: string | string[] | null,
block: string
) {
console.log(e, inputValue, block);
//condition to fix bug control+backspace on Windows/Linux
if (
typeof inputValue === "string" &&
e.ctrlKey === true &&
e.key === "Backspace" &&
(inputValue === block ||
inputValue?.charAt(inputValue?.length - 1) === " " ||
specialCharsRegex.test(inputValue?.charAt(inputValue?.length - 1)))
) {
e.preventDefault();
e.stopPropagation();
}
//condition to fix bug control+backspace on Mac
if (
typeof inputValue === "string" &&
e.metaKey === true &&
e.key === "Backspace" &&
(inputValue === block ||
inputValue?.charAt(inputValue?.length - 1) === " " ||
specialCharsRegex.test(inputValue?.charAt(inputValue?.length - 1)))
(typeof inputValue === "string" &&
(e.metaKey === true || e.ctrlKey === true) &&
e.key === "Backspace" &&
(inputValue === block ||
inputValue?.charAt(inputValue?.length - 1) === " " ||
specialCharsRegex.test(inputValue?.charAt(inputValue?.length - 1)))) ||
(navigator.userAgent.toUpperCase().includes("MAC") &&
e.ctrlKey === true &&
e.key === "Backspace")
) {
e.preventDefault();
e.stopPropagation();