Skip to content

Commit 6a4f5ee

Browse files
Merge pull request #14139 from guardian/rejig-datawrapper-dark-mode-check
2 parents 6fd8363 + 6c13677 commit 6a4f5ee

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

dotcom-rendering/src/components/InteractiveBlockComponent.importable.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ export const InteractiveBlockComponent = ({
325325
const wrapperRef = useRef<HTMLDivElement>(null);
326326
const placeholderLinkRef = useRef<HTMLAnchorElement>(null);
327327
const [loaded, setLoaded] = useState(false);
328-
const { darkModeAvailable } = useConfig();
328+
const { darkModeAvailable, renderingTarget } = useConfig();
329329

330330
// Define some one-time flags
331331
const isDatawrapperGraphic =
@@ -352,13 +352,6 @@ export const InteractiveBlockComponent = ({
352352
useOnce(() => {
353353
// We've brought the behavior from boot.js into this file to avoid loading 2 extra scripts
354354

355-
// Define additional one-time flags - these depend on window/document objects
356-
const isRunningInWebEnvironment =
357-
!document.querySelector('.ios') &&
358-
!document.querySelector('.android')
359-
? true
360-
: false;
361-
362355
const prefersDarkScheme = window.matchMedia(
363356
'(prefers-color-scheme: dark)',
364357
).matches;
@@ -382,7 +375,7 @@ export const InteractiveBlockComponent = ({
382375
}
383376

384377
// Fix darkmode for web environment
385-
if (isRunningInWebEnvironment && !requiresDarkMode) {
378+
if (renderingTarget === 'Web' && !requiresDarkMode) {
386379
if (isDatawrapperGraphic || isUploaderEmbedPath) {
387380
// Add the 'dark=false' search param
388381
if (graphicUrl.search.length) {

0 commit comments

Comments
 (0)