From 8fee7c46c16cbc1b46477cf600160f9668b9f5d0 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 9 Jun 2022 01:19:06 +0800 Subject: [PATCH] Fix viewed images not loading in a PR (#19919) Close #19651 --- web_src/js/features/imagediff.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web_src/js/features/imagediff.js b/web_src/js/features/imagediff.js index 174533176..0b021d070 100644 --- a/web_src/js/features/imagediff.js +++ b/web_src/js/features/imagediff.js @@ -67,7 +67,8 @@ export default function initImageDiff() { $('.image-diff').each(function() { const $container = $(this); - const diffContainerWidth = $container.width() - 300; + // the container may be hidden by "viewed" checkbox, so use the parent's width for reference + const diffContainerWidth = Math.max($container.closest('.diff-file-box').width() - 300, 100); const pathAfter = $container.data('path-after'); const pathBefore = $container.data('path-before');