Skip to content

Commit

Permalink
fix(interpretations): plugin flashes when interacting with Interpreta…
Browse files Browse the repository at this point in the history
…tions modal (#1608)

Part of fix for https://dhis2.atlassian.net/browse/DHIS2-15570

Memoize the filter object to prevent unnecessary refetching/re-rendering.
  • Loading branch information
jenniferarnesen authored Apr 22, 2024
1 parent 21f8775 commit e65e917
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '@dhis2/ui'
import cx from 'classnames'
import PropTypes from 'prop-types'
import React, { useEffect, useState } from 'react'
import React, { useEffect, useState, useMemo } from 'react'
import css from 'styled-jsx/css'
import { InterpretationThread } from './InterpretationThread.js'
import { useModalContentWidth } from './useModalContentWidth.js'
Expand Down Expand Up @@ -116,6 +116,12 @@ const InterpretationModal = ({
}
}, [interpretationId, refetch])

const filters = useMemo(() => {
return {
relativePeriodDate: interpretation?.created,
}
}, [interpretation?.created])

return (
<>
{loadingInProgress && (
Expand Down Expand Up @@ -163,10 +169,7 @@ const InterpretationModal = ({
<div className="row">
<div className="visualisation-wrap">
<VisualizationPlugin
filters={{
relativePeriodDate:
interpretation.created,
}}
filters={filters}
visualization={visualization}
onResponsesReceived={
onResponsesReceived
Expand All @@ -175,6 +178,7 @@ const InterpretationModal = ({
currentUser.settings
?.keyAnalysisDisplayProperty
}
isInModal={true}
/>
</div>
<div className="thread-wrap">
Expand Down

0 comments on commit e65e917

Please sign in to comment.