From dc9ee50c4626f81abfae62aa0d1cf11ee225a507 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Tue, 1 Nov 2022 18:49:00 +0100 Subject: [PATCH] Media Viewer: Various fixes (follow-up) --- src/components/mediaViewer/MediaViewer.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/mediaViewer/MediaViewer.tsx b/src/components/mediaViewer/MediaViewer.tsx index 50cf46c2a..41f588fd7 100644 --- a/src/components/mediaViewer/MediaViewer.tsx +++ b/src/components/mediaViewer/MediaViewer.tsx @@ -27,7 +27,7 @@ import { } from '../../global/selectors'; import { stopCurrentAudio } from '../../util/audioPlayer'; import captureEscKeyListener from '../../util/captureEscKeyListener'; -import { IS_SINGLE_COLUMN_LAYOUT } from '../../util/environment'; +import { IS_SINGLE_COLUMN_LAYOUT, IS_TOUCH_ENV } from '../../util/environment'; import { ANIMATION_END_DELAY } from '../../config'; import { MEDIA_VIEWER_MEDIA_QUERY } from '../common/helpers/mediaDimensions'; import windowSize from '../../util/windowSize'; @@ -151,8 +151,13 @@ const MediaViewer: FC = ({ }, [isVisible]); useEffect(() => { - if (!IS_SINGLE_COLUMN_LAYOUT) return; - document.body.classList.toggle('is-media-viewer-open', isOpen); + if (IS_SINGLE_COLUMN_LAYOUT) { + document.body.classList.toggle('is-media-viewer-open', isOpen); + } + // Disable user selection if media viewer is open, to prevent accidental text selection + if (IS_TOUCH_ENV) { + document.body.classList.toggle('no-selection', isOpen); + } }, [isOpen]); const forceUpdate = useForceUpdate();