Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reload iframe plugins when filters causing errors are changed/removed #2675

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const IframePlugin = ({
}
}
}, [
error,
recordOnNextLoad,
pluginProps,
iframeSrc,
Expand Down Expand Up @@ -190,6 +191,7 @@ const IframePlugin = ({
}, [pluginType, dispatch, visualization, iframePluginStatus, isFirstOfType])

useEffect(() => {
prevPluginRef.current = undefined
setError(null)
}, [filterVersion, visualization.type])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import i18n from '@dhis2/d2-i18n'
import { Button, Cover, IconInfo24, IconWarning24, colors } from '@dhis2/ui'
import uniqueId from 'lodash/uniqueId.js'
import PropTypes from 'prop-types'
import React, { useMemo } from 'react'
import React, { useCallback, useMemo } from 'react'
import { useSelector } from 'react-redux'
import {
isLLVersionCompatible,
Expand Down Expand Up @@ -73,14 +73,13 @@ const Visualization = ({
)
}, [visualization, activeType, originalType, itemFilters])

const filterVersion = useMemo(() => uniqueId(), [])
const filterVersion = useCallback(() => uniqueId(), [])

const iFramePluginProps = useMemo(
() => ({
originalType,
activeType,
style,
filterVersion,
dashboardMode,
dashboardId,
itemId: item.id,
Expand All @@ -91,7 +90,6 @@ const Visualization = ({
originalType,
activeType,
style,
filterVersion,
dashboardMode,
dashboardId,
item.id,
Expand Down Expand Up @@ -140,6 +138,7 @@ const Visualization = ({
return (
<IframePlugin
visualization={visualizationConfig}
filterVersion={filterVersion()}
{...iFramePluginProps}
/>
)
Expand Down Expand Up @@ -213,7 +212,7 @@ const Visualization = ({
item={item}
activeType={activeType}
visualization={visualizationConfig}
filterVersion={filterVersion}
filterVersion={filterVersion()}
style={style}
gridWidth={gridWidth}
{...rest}
Expand Down
Loading