fix hover again perhaps

This commit is contained in:
7w1 committed 2026-07-20 23:47:35 -05:00
1 parent 931968f89d
commit c7a475a004
5 files changed
+45 -33

No files matched your search

@@ -0,0 +1,5 @@
---
default: patch
---
Fix sliding sync not subscribing to call updates.
+8 -6
View File
@@ -354,9 +354,10 @@ export function RoomNavItem({
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
const {
onTouchStart,
onTouchEnd,
onTouchMove,
onPointerDown,
onPointerUp,
onPointerMove,
onPointerCancel,
firedRef: longPressFiredRef,
isPressing,
} = useMobileLongPress(() => {
@@ -457,9 +458,10 @@ export function RoomNavItem({
userSelect: 'none',
WebkitUserSelect: 'none',
}}
onTouchStart={onTouchStart}
onTouchEnd={onTouchEnd}
onTouchMove={onTouchMove}
onPointerDown={onPointerDown}
onPointerUp={onPointerUp}
onPointerMove={onPointerMove}
onPointerCancel={onPointerCancel}
>
<NavItem
variant="Background"
+9 -6
View File
@@ -834,9 +834,10 @@ function MessageInternal(
};
const {
onTouchStart,
onTouchEnd,
onTouchMove,
onPointerDown,
onPointerUp,
onPointerMove,
onPointerCancel,
firedRef: longPressFiredRef,
isPressing,
} = useMobileLongPress(() => {
@@ -893,6 +894,7 @@ function MessageInternal(
<MessageBase
className={classNames(css.MessageBase, className, {
[css.MessageBaseBubbleCollapsed]: messageLayout === MessageLayout.Bubble && collapse,
[css.MessageForceHover]: isPressing || isEmoji || !!menuAnchor,
})}
tabIndex={0}
space={messageSpacing}
@@ -935,9 +937,10 @@ function MessageInternal(
<div
style={{ width: '100%' }}
onContextMenu={handleContextMenu}
onTouchStart={onTouchStart}
onTouchEnd={onTouchEnd}
onTouchMove={onTouchMove}
onPointerDown={onPointerDown}
onPointerUp={onPointerUp}
onPointerMove={onPointerMove}
onPointerCancel={onPointerCancel}
>
<WrappedMessage
headerJSX={headerJSX(collapse)}
@@ -9,6 +9,10 @@ export const MessageBaseBubbleCollapsed = style({
paddingTop: 0,
});
export const MessageForceHover = style({
backgroundColor: color.Surface.ContainerHover,
});
export const MessageOptionsBase = style([
DefaultReset,
{
+19 -21
View File
@@ -1,12 +1,11 @@
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 touchStartY = useRef<number | null>(null);
const touchStartX = useRef<number | null>(null);
const startY = useRef<number | null>(null);
const startX = useRef<number | null>(null);
const clear = useCallback(() => {
if (timerRef.current !== null) {
@@ -14,19 +13,18 @@ export function useMobileLongPress(callback: () => void, delay = 500) {
timerRef.current = null;
}
setIsPressing(false);
touchStartY.current = null;
touchStartX.current = null;
startY.current = null;
startX.current = null;
}, []);
const onTouchStart = useCallback(
(e: React.TouchEvent | TouchEvent) => {
if (!mobileOrTablet()) return;
const onPointerDown = useCallback(
(e: React.PointerEvent | PointerEvent) => {
if (e.pointerType !== 'touch') return;
firedRef.current = false;
setIsPressing(true);
if (e.touches && e.touches[0]) {
touchStartY.current = e.touches[0].clientY;
touchStartX.current = e.touches[0].clientX;
}
startY.current = e.clientY;
startX.current = e.clientX;
timerRef.current = setTimeout(() => {
firedRef.current = true;
setIsPressing(false);
@@ -36,20 +34,18 @@ export function useMobileLongPress(callback: () => void, delay = 500) {
[callback, delay]
);
const onTouchEnd = useCallback(() => {
const onPointerUp = useCallback(() => {
clear();
}, [clear]);
const onTouchMove = useCallback(
(e: React.TouchEvent | TouchEvent) => {
if (touchStartY.current === null || touchStartX.current === null || !e.touches || !e.touches[0]) {
const onPointerMove = useCallback(
(e: React.PointerEvent | PointerEvent) => {
if (startY.current === null || startX.current === null || e.pointerType !== 'touch') {
clear();
return;
}
const currentY = e.touches[0].clientY;
const currentX = e.touches[0].clientX;
const diffY = Math.abs(currentY - touchStartY.current);
const diffX = Math.abs(currentX - touchStartX.current);
const diffY = Math.abs(e.clientY - startY.current);
const diffX = Math.abs(e.clientX - startX.current);
if (diffY > 10 || diffX > 10) {
clear();
@@ -58,5 +54,7 @@ export function useMobileLongPress(callback: () => void, delay = 500) {
[clear]
);
return { onTouchStart, onTouchEnd, onTouchMove, firedRef, isPressing };
const onPointerCancel = useCallback(() => clear(), [clear]);
return { onPointerDown, onPointerUp, onPointerMove, onPointerCancel, firedRef, isPressing };
}