Skip to content

Commit

Permalink
Fix #8755 issue with the chart selector title (#9671)
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap authored Oct 27, 2023
1 parent 2c97213 commit 7c71fbf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions web/client/components/widgets/builder/wizard/ChartWizard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ const ChartWizard = ({
onFilterLayer={() => openFilterEditor()}
/>}
<ChartStyleEditorComp
// force the re-rendering on trace change
key={selectedTrace?.id}
data={selectedTrace}
layer={selectedTrace?.layer}
featureTypeProperties={featureTypeProperties}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ export default ({
noResultsText="widgets.chartSwitcher.noResults"
options={isEmpty(options)
? []
: options.map(m => ({
label: m?.name || (m?.layer?.title),
: options.map((m, idx) => ({
// layer cannot be used anymore as default
// because a chart could contain multiple layers
label: m?.name || `[Chart ${idx + 1}]`,
value: m.chartId
}))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import ReactTestUtils from 'react-dom/test-utils';

import ChartSwitcher from '../ChartSwitcher';

const charts = [{chartId: 1, layer: {title: 'm1'}}, {chartId: 2, layer: {title: 'm2'}}];
const charts = [{chartId: 1}, {chartId: 2}];
describe('ChartSwitcher component', () => {
beforeEach((done) => {
document.body.innerHTML = '<div id="container"></div>';
Expand All @@ -32,7 +32,7 @@ describe('ChartSwitcher component', () => {
const switcherDropdown = container.querySelector('.Select');
expect(switcherDropdown).toBeTruthy();
const switcherValue = container.querySelector('.Select-value-label');
expect(switcherValue.textContent).toBe('m1');
expect(switcherValue.textContent).toBe('[Chart 1]');
});
it('ChartSwitcher render without container', () => {
ReactDOM.render(<ChartSwitcher charts={charts}/>, document.getElementById("container"));
Expand Down

0 comments on commit 7c71fbf

Please sign in to comment.