Ignore gestures on horizontally scrolling elements

This commit is contained in:
Evelyn Gordon committed 2026-08-12 23:52:29 -05:00
1 parent 8771549911
commit f498dbfba2
4 files changed
+24 -4

No files matched your search

@@ -242,7 +242,7 @@ function MarkdownToolbar() {
return (
<Box className={`${css.EditorToolbarBase} ${floatingToolbar}`}>
<Scroll direction="Horizontal" size="0">
<Scroll direction="Horizontal" size="0" data-gestures="scroll">
<Box className={css.EditorToolbar} alignItems="Center" gap="300">
<Box shrink="No" gap="100">
<MarkdownInlineButton
+8 -1
View File
@@ -351,15 +351,22 @@ export function MobileNavDrawer({ nav, rail, bottomNav, children }: MobileNavDra
const messageElement = target.closest<HTMLElement>('[data-message-swipe]');
const chatElement = target.closest<HTMLElement>('[data-chat-swipe]');
const ignoredElement = target.closest<HTMLElement>('[data-gestures="ignore"]');
const scrollingElement = target.closest<HTMLElement>('[data-gestures="scroll"]');
const message = messageElement ? messageTargetsRef.current.get(messageElement) : undefined;
const chat = chatElement ? chatTargetsRef.current.get(chatElement) : undefined;
// Nested ignore markers (e.g. inline media) don't block swipe if they're part of
// this message/chat's own surface, only if they sit outside it.
const blocked =
const blockedIgnored =
ignoredElement !== null &&
!(messageElement && messageElement.contains(ignoredElement)) &&
!(chatElement && chatElement.contains(ignoredElement));
// If the element is horizontally scrollable (scrollWidth > clientWidth), block gestures
const blockedScroll =
scrollingElement !== null && scrollingElement.scrollWidth > scrollingElement.clientWidth;
const blocked = blockedScroll || blockedIgnored;
gestureRef.current = {
startX: touch.clientX,
startY: touch.clientY,
@@ -432,7 +432,14 @@ export const UrlPreviewHolder = as<'div'>(({ children, ...props }, ref) => {
ref={ref}
style={{ marginTop: config.space.S200, position: 'relative' }}
>
<Scroll ref={scrollRef} direction="Horizontal" size="0" visibility="Hover" hideTrack>
<Scroll
ref={scrollRef}
direction="Horizontal"
size="0"
visibility="Hover"
hideTrack
data-gestures="scroll"
>
<Box shrink="No" alignItems="Center">
{canScrollLeft && (
<>
+7 -1
View File
@@ -2052,7 +2052,13 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
}
>
{uploadBoard && (
<Scroll direction="Horizontal" size="300" hideTrack visibility="Hover">
<Scroll
direction="Horizontal"
size="300"
hideTrack
visibility="Hover"
data-gestures="scroll"
>
<UploadBoardContent>
{Array.from(selectedFiles)
.toReversed()