Forward Modal: Send from forward modal on Enter key (#6964)
This commit is contained in:
parent
e6ba963240
commit
37c3156493
@ -57,6 +57,14 @@ const PickerItem = ({
|
|||||||
onClick?.();
|
onClick?.();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleKeyDown = useLastCallback((e: React.KeyboardEvent<HTMLDivElement>) => {
|
||||||
|
if (e.key !== ' ') return;
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
handleClick();
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={buildClassName(
|
className={buildClassName(
|
||||||
@ -68,6 +76,7 @@ const PickerItem = ({
|
|||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
|
onKeyDown={isClickable ? handleKeyDown : undefined}
|
||||||
style={style}
|
style={style}
|
||||||
dir={lang.isRtl ? 'rtl' : undefined}
|
dir={lang.isRtl ? 'rtl' : undefined}
|
||||||
role={isClickable ? 'button' : undefined}
|
role={isClickable ? 'button' : undefined}
|
||||||
|
|||||||
@ -17,6 +17,7 @@ import {
|
|||||||
selectUser,
|
selectUser,
|
||||||
} from '../../global/selectors';
|
} from '../../global/selectors';
|
||||||
import buildClassName from '../../util/buildClassName';
|
import buildClassName from '../../util/buildClassName';
|
||||||
|
import captureKeyboardListeners from '../../util/captureKeyboardListeners';
|
||||||
import { isUserId } from '../../util/entities/ids';
|
import { isUserId } from '../../util/entities/ids';
|
||||||
import { formatStarsAsIcon, formatStarsAsText } from '../../util/localization/format';
|
import { formatStarsAsIcon, formatStarsAsText } from '../../util/localization/format';
|
||||||
|
|
||||||
@ -222,6 +223,32 @@ const ForwardRecipientPicker: FC<OwnProps & StateProps> = ({
|
|||||||
executeForward();
|
executeForward();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleEnterShortcut = useLastCallback((e: KeyboardEvent) => {
|
||||||
|
if (e.isComposing || e.metaKey || e.ctrlKey || e.altKey || e.shiftKey) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!selectedIds.length) {
|
||||||
|
if (!canCopyLink) return false;
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
handleCopyLink();
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
handleForwardToMultiple();
|
||||||
|
return undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isOpen || !isMultiSelect || isPaymentConfirmOpen) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return captureKeyboardListeners({ onEnter: handleEnterShortcut });
|
||||||
|
}, [isOpen, isMultiSelect, isPaymentConfirmOpen, handleEnterShortcut]);
|
||||||
|
|
||||||
const executeForward = useLastCallback(() => {
|
const executeForward = useLastCallback(() => {
|
||||||
const targets: ForwardTarget[] = selectedIds.map(({ peerId, topicId }) => ({
|
const targets: ForwardTarget[] = selectedIds.map(({ peerId, topicId }) => ({
|
||||||
chatId: peerId,
|
chatId: peerId,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user