From d9f195db2ac91bfbcda7b6909f4e7ed78c0b123a Mon Sep 17 00:00:00 2001 From: Marc Woolfson Date: Thu, 23 Jan 2025 12:50:46 +0000 Subject: [PATCH] feat: Ensured if 'table' mode selected in chart radios then first select 'chart' before saving chart images --- .../src/components/chart-mode/component.tsx | 2 +- .../charts/horizontal-bar-chart/component.tsx | 1 + .../src/components/charts/line-chart/component.tsx | 1 + .../charts/vertical-bar-chart/component.tsx | 6 +++++- .../share-content-by-elements/component.tsx | 9 ++++++++- .../components/share-content-by-elements/types.tsx | 1 + front-end-components/src/main.tsx | 13 +++++++++++++ .../Pages/Schools/WhenViewingComparison.cs | 2 +- .../Pages/Trusts/WhenViewingComparison.cs | 2 +- 9 files changed, 32 insertions(+), 5 deletions(-) diff --git a/front-end-components/src/components/chart-mode/component.tsx b/front-end-components/src/components/chart-mode/component.tsx index fbbb5814a..fdbb8b623 100644 --- a/front-end-components/src/components/chart-mode/component.tsx +++ b/front-end-components/src/components/chart-mode/component.tsx @@ -15,7 +15,7 @@ export const ChartMode: React.FC = (props) => {

View as

diff --git a/front-end-components/src/components/charts/horizontal-bar-chart/component.tsx b/front-end-components/src/components/charts/horizontal-bar-chart/component.tsx index 7cdbcb090..56bdb8dd5 100644 --- a/front-end-components/src/components/charts/horizontal-bar-chart/component.tsx +++ b/front-end-components/src/components/charts/horizontal-bar-chart/component.tsx @@ -280,6 +280,7 @@ function HorizontalBarChartInner( key={seriesName as string} dataKey={seriesName as string} stackId={config?.stackId} + isAnimationActive={false} > {filteredData.map((entry, dataIndex) => renderCell(entry, dataIndex, seriesIndex, config) diff --git a/front-end-components/src/components/charts/line-chart/component.tsx b/front-end-components/src/components/charts/line-chart/component.tsx index 2b8032f6b..1c6580d52 100644 --- a/front-end-components/src/components/charts/line-chart/component.tsx +++ b/front-end-components/src/components/charts/line-chart/component.tsx @@ -187,6 +187,7 @@ function LineChartInner( true ) } + isAnimationActive={false} > ); }; diff --git a/front-end-components/src/components/charts/vertical-bar-chart/component.tsx b/front-end-components/src/components/charts/vertical-bar-chart/component.tsx index 7f0d21c56..0c224f146 100644 --- a/front-end-components/src/components/charts/vertical-bar-chart/component.tsx +++ b/front-end-components/src/components/charts/vertical-bar-chart/component.tsx @@ -176,7 +176,11 @@ function VerticalBarChartInner( /> )} {visibleSeriesNames.map((seriesName, seriesIndex) => ( - + {data.map((entry, dataIndex) => renderCell(entry, dataIndex, seriesName, seriesIndex) )} diff --git a/front-end-components/src/components/share-content-by-elements/component.tsx b/front-end-components/src/components/share-content-by-elements/component.tsx index c7aaf18a7..2a5f79f5c 100644 --- a/front-end-components/src/components/share-content-by-elements/component.tsx +++ b/front-end-components/src/components/share-content-by-elements/component.tsx @@ -10,6 +10,7 @@ export const ShareContentByElements: React.FC = ({ showProgress, showTitles, label, + onClick, ...props }) => { const [imagesLoading, setImagesLoading] = useState(); @@ -31,7 +32,13 @@ export const ShareContentByElements: React.FC = ({ return ( await downloadPngs()} + onSaveClick={async () => { + if (onClick) { + await onClick(); + } + + await downloadPngs(); + }} {...props} > <> diff --git a/front-end-components/src/components/share-content-by-elements/types.tsx b/front-end-components/src/components/share-content-by-elements/types.tsx index f94b7d169..d475e9ace 100644 --- a/front-end-components/src/components/share-content-by-elements/types.tsx +++ b/front-end-components/src/components/share-content-by-elements/types.tsx @@ -11,6 +11,7 @@ export type ShareContentByElementsProps = Omit< > & { elementsSelector: () => ElementAndTitle[]; label: string; + onClick: () => Promise; showProgress?: boolean; showTitles?: boolean; }; diff --git a/front-end-components/src/main.tsx b/front-end-components/src/main.tsx index c3d5d13e7..c584c602c 100644 --- a/front-end-components/src/main.tsx +++ b/front-end-components/src/main.tsx @@ -913,6 +913,19 @@ if (shareContentByElementClassNameElements) { root.render( { + const radio = document.getElementById( + "mode-chart" + ) as HTMLInputElement; + if (radio && radio.checked === false) { + radio.click(); + await new Promise((resolve) => { + setTimeout(() => { + resolve(); + }, 1000); + }); + } + }} elementsSelector={() => { const results = []; const elements = diff --git a/web/tests/Web.Integration.Tests/Pages/Schools/WhenViewingComparison.cs b/web/tests/Web.Integration.Tests/Pages/Schools/WhenViewingComparison.cs index 7130ed766..9cbdd101e 100644 --- a/web/tests/Web.Integration.Tests/Pages/Schools/WhenViewingComparison.cs +++ b/web/tests/Web.Integration.Tests/Pages/Schools/WhenViewingComparison.cs @@ -127,7 +127,7 @@ private static void AssertPageLayout(IHtmlDocument page, School school) var comparisonComponent = page.GetElementById("compare-your-costs"); Assert.NotNull(comparisonComponent); - var toolsListSection = page.Body.SelectSingleNode("//main/div/div[5]"); + var toolsListSection = page.Body.SelectSingleNode("//main/div/div[6]"); DocumentAssert.Heading2(toolsListSection, "Benchmarking and planning tools"); var toolsLinks = toolsListSection.ChildNodes.QuerySelectorAll("ul> li > h3 > a").ToList(); diff --git a/web/tests/Web.Integration.Tests/Pages/Trusts/WhenViewingComparison.cs b/web/tests/Web.Integration.Tests/Pages/Trusts/WhenViewingComparison.cs index cef1244ce..2c39e1ef8 100644 --- a/web/tests/Web.Integration.Tests/Pages/Trusts/WhenViewingComparison.cs +++ b/web/tests/Web.Integration.Tests/Pages/Trusts/WhenViewingComparison.cs @@ -107,7 +107,7 @@ private static void AssertPageLayout(IHtmlDocument page, Trust trust) Assert.Equal(expectedPhases.ToJson(Formatting.None), dataPhases); - var toolsSection = page.Body.SelectSingleNode("//main/div/div[4]"); + var toolsSection = page.Body.SelectSingleNode("//main/div/div[5]"); DocumentAssert.Heading2(toolsSection, "Benchmarking and planning tools"); var toolsLinks = toolsSection.ChildNodes.QuerySelectorAll("ul> li > h3 > a").ToList();