fix(ui): prevent mobile touch events from triggering playback after lightbox close
Signed-off-by: Deluan <deluan@navidrome.org>
This commit is contained in:
@@ -85,7 +85,14 @@ const DiscSubtitleRow = forwardRef(
|
|||||||
const classes = useStyles({ isDesktop })
|
const classes = useStyles({ isDesktop })
|
||||||
const [imageError, setImageError] = useState(false)
|
const [imageError, setImageError] = useState(false)
|
||||||
const [isLightboxOpen, setLightboxOpen] = useState(false)
|
const [isLightboxOpen, setLightboxOpen] = useState(false)
|
||||||
|
const lightboxClosedAt = React.useRef(0)
|
||||||
const handlePlaySubset = (discNumber) => () => {
|
const handlePlaySubset = (discNumber) => () => {
|
||||||
|
// Ignore clicks shortly after the lightbox was closed to prevent
|
||||||
|
// mobile touch events from "falling through" the overlay and
|
||||||
|
// triggering playback.
|
||||||
|
if (Date.now() - lightboxClosedAt.current < 400) {
|
||||||
|
return
|
||||||
|
}
|
||||||
onClick(discNumber)
|
onClick(discNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +119,10 @@ const DiscSubtitleRow = forwardRef(
|
|||||||
[imageError],
|
[imageError],
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleCloseLightbox = useCallback(() => setLightboxOpen(false), [])
|
const handleCloseLightbox = useCallback(() => {
|
||||||
|
lightboxClosedAt.current = Date.now()
|
||||||
|
setLightboxOpen(false)
|
||||||
|
}, [])
|
||||||
|
|
||||||
const subtitle = record.discSubtitle
|
const subtitle = record.discSubtitle
|
||||||
? record.discSubtitle
|
? record.discSubtitle
|
||||||
|
|||||||
Reference in New Issue
Block a user