mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-02 17:48:34 +01:00
Message: Allow system context menu for links (#1105)
This commit is contained in:
parent
3520854116
commit
08cfbd9d25
@ -231,7 +231,7 @@ const Message: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
isContextMenuOpen, contextMenuPosition,
|
||||
handleBeforeContextMenu, handleContextMenu,
|
||||
handleContextMenuClose, handleContextMenuHide,
|
||||
} = useContextMenuHandlers(ref);
|
||||
} = useContextMenuHandlers(ref, false, true);
|
||||
|
||||
const noAppearanceAnimation = appearanceOrder <= 0;
|
||||
const [isShown, markShown] = useFlag(noAppearanceAnimation);
|
||||
|
@ -17,6 +17,7 @@ function checkIsDisabledForMobile() {
|
||||
export default (
|
||||
elementRef: RefObject<HTMLElement>,
|
||||
isMenuDisabled?: boolean,
|
||||
shouldDisableOnLink?: boolean,
|
||||
) => {
|
||||
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false);
|
||||
const [contextMenuPosition, setContextMenuPosition] = useState<IAnchorPosition | undefined>(undefined);
|
||||
@ -28,11 +29,12 @@ export default (
|
||||
}, [isMenuDisabled]);
|
||||
|
||||
const handleContextMenu = useCallback((e: React.MouseEvent) => {
|
||||
if (isMenuDisabled) {
|
||||
document.body.classList.remove('no-selection');
|
||||
|
||||
if (isMenuDisabled || (shouldDisableOnLink && (e.target as HTMLElement).matches('a.text-entity-link[href]'))) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
document.body.classList.remove('no-selection');
|
||||
|
||||
if (contextMenuPosition) {
|
||||
return;
|
||||
@ -45,7 +47,7 @@ export default (
|
||||
|
||||
setIsContextMenuOpen(true);
|
||||
setContextMenuPosition({ x: e.clientX, y: e.clientY });
|
||||
}, [isMenuDisabled, contextMenuPosition]);
|
||||
}, [isMenuDisabled, shouldDisableOnLink, contextMenuPosition]);
|
||||
|
||||
const handleContextMenuClose = useCallback(() => {
|
||||
setIsContextMenuOpen(false);
|
||||
|
Loading…
Reference in New Issue
Block a user