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?.();
|
||||
});
|
||||
|
||||
const handleKeyDown = useLastCallback((e: React.KeyboardEvent<HTMLDivElement>) => {
|
||||
if (e.key !== ' ') return;
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
handleClick();
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
className={buildClassName(
|
||||
@ -68,6 +76,7 @@ const PickerItem = ({
|
||||
className,
|
||||
)}
|
||||
onClick={handleClick}
|
||||
onKeyDown={isClickable ? handleKeyDown : undefined}
|
||||
style={style}
|
||||
dir={lang.isRtl ? 'rtl' : undefined}
|
||||
role={isClickable ? 'button' : undefined}
|
||||
|
||||
@ -17,6 +17,7 @@ import {
|
||||
selectUser,
|
||||
} from '../../global/selectors';
|
||||
import buildClassName from '../../util/buildClassName';
|
||||
import captureKeyboardListeners from '../../util/captureKeyboardListeners';
|
||||
import { isUserId } from '../../util/entities/ids';
|
||||
import { formatStarsAsIcon, formatStarsAsText } from '../../util/localization/format';
|
||||
|
||||
@ -222,6 +223,32 @@ const ForwardRecipientPicker: FC<OwnProps & StateProps> = ({
|
||||
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 targets: ForwardTarget[] = selectedIds.map(({ peerId, topicId }) => ({
|
||||
chatId: peerId,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user