Attachment Modal: Various fixes (#2675)

This commit is contained in:
Alexander Zinchuk 2023-02-25 18:50:33 +01:00
parent e3e2d7d5b5
commit 9ccc7e3ff9
4 changed files with 8 additions and 9 deletions

View File

@ -466,8 +466,7 @@
flex-grow: 1; flex-grow: 1;
.form-control { .form-control {
padding: calc((3.5rem - var(--composer-text-size, 1rem) * 1.375) / 2 - var(--border-width, 0) * 2) padding: calc((3.5rem - var(--composer-text-size, 1rem) * 1.375) / 2) 0.875rem;
calc(0.9rem - var(--border-width));
overflow: hidden; overflow: hidden;
height: auto; height: auto;
line-height: 1.375; line-height: 1.375;

View File

@ -71,7 +71,7 @@ const MAX_ATTACHMENT_MODAL_INPUT_HEIGHT = 160;
const TAB_INDEX_PRIORITY_TIMEOUT = 2000; const TAB_INDEX_PRIORITY_TIMEOUT = 2000;
// Heuristics allowing the user to make a triple click // Heuristics allowing the user to make a triple click
const SELECTION_RECALCULATE_DELAY_MS = 260; const SELECTION_RECALCULATE_DELAY_MS = 260;
const TEXT_FORMATTER_SAFE_AREA_PX = 90; const TEXT_FORMATTER_SAFE_AREA_PX = 140;
// 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>';
const IGNORE_KEYS = [ const IGNORE_KEYS = [

View File

@ -75,6 +75,7 @@ const TextFormatter: FC<OwnProps> = ({
isOpen, isOpen,
containerRef, containerRef,
onClose, onClose,
true,
); );
useEffect(() => { useEffect(() => {

View File

@ -9,12 +9,13 @@ export default function useVirtualBackdrop(
isOpen: boolean, isOpen: boolean,
menuRef: RefObject<HTMLElement>, menuRef: RefObject<HTMLElement>,
onClose?: () => void | undefined, onClose?: () => void | undefined,
ignoreRightClick?: boolean,
) { ) {
useEffect(() => { useEffect(() => {
const handleEvent = (e: Event) => { const handleEvent = (e: MouseEvent) => {
const menu = menuRef.current; const menu = menuRef.current;
const target = e.target as HTMLElement | null; const target = e.target as HTMLElement | null;
if (!menu || !target) { if (!menu || !target || (ignoreRightClick && e.button === 2)) {
return; return;
} }
@ -24,9 +25,7 @@ export default function useVirtualBackdrop(
) { ) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
if (onClose) { onClose?.();
onClose();
}
} }
}; };
@ -37,5 +36,5 @@ export default function useVirtualBackdrop(
return () => { return () => {
document.removeEventListener('mousedown', handleEvent); document.removeEventListener('mousedown', handleEvent);
}; };
}, [isOpen, menuRef, onClose]); }, [ignoreRightClick, isOpen, menuRef, onClose]);
} }