add visual indication when pressing on message

This commit is contained in:
7w1 committed 2026-07-20 23:31:42 -05:00
1 parent b5eeae70bf
commit 4f77d641be
3 files changed
+16 -5

No files matched your search

+8 -2
View File
@@ -351,7 +351,13 @@ export function RoomNavItem({
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
const { onTouchStart, onTouchEnd, onTouchMove, firedRef: longPressFiredRef } = useMobileLongPress(() => {
const {
onTouchStart,
onTouchEnd,
onTouchMove,
firedRef: longPressFiredRef,
isPressing,
} = useMobileLongPress(() => {
setIsMobileMenuOpen(true);
});
@@ -458,7 +464,7 @@ export function RoomNavItem({
radii="400"
highlight={shouldShowUnreadIndicator}
aria-selected={selected}
data-hover={!!menuAnchor}
data-hover={!!menuAnchor || isPressing || isMobileMenuOpen}
onContextMenu={handleContextMenu}
{...hoverProps}
{...focusWithinProps}
+2 -1
View File
@@ -838,6 +838,7 @@ function MessageInternal(
onTouchEnd,
onTouchMove,
firedRef: longPressFiredRef,
isPressing,
} = useMobileLongPress(() => {
if (!edit) openMobileOptions();
});
@@ -898,7 +899,7 @@ function MessageInternal(
collapse={collapse}
highlight={highlight}
notifyHighlight={highlightMentions ? notifyHighlight : undefined}
selected={!!menuAnchor || isEmoji}
selected={!!menuAnchor || isEmoji || isPressing}
isMarked={isMarked}
mobile={mobileOrTablet()}
{...props}
+6 -2
View File
@@ -1,22 +1,26 @@
import { useRef, useCallback } from 'react';
import { useRef, useCallback, useState } from 'react';
import { mobileOrTablet } from '$utils/user-agent';
export function useMobileLongPress(callback: () => void, delay = 500) {
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const firedRef = useRef(false);
const [isPressing, setIsPressing] = useState(false);
const clear = useCallback(() => {
if (timerRef.current !== null) {
clearTimeout(timerRef.current);
timerRef.current = null;
}
setIsPressing(false);
}, []);
const onTouchStart = useCallback(() => {
if (!mobileOrTablet()) return;
firedRef.current = false;
setIsPressing(true);
timerRef.current = setTimeout(() => {
firedRef.current = true;
setIsPressing(false);
callback();
}, delay);
}, [callback, delay]);
@@ -29,5 +33,5 @@ export function useMobileLongPress(callback: () => void, delay = 500) {
clear();
}, [clear]);
return { onTouchStart, onTouchEnd, onTouchMove, firedRef };
return { onTouchStart, onTouchEnd, onTouchMove, firedRef, isPressing };
}