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 (#1653)

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 6e4b817 commit 17d8e12
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 @@ -115,6 +115,12 @@ const InterpretationModal = ({
}
}, [interpretationId, refetch])

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

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

0 comments on commit 17d8e12

Please sign in to comment.