[Lens] Fix state setting via mutation (#104420)
This commit is contained in:
parent
f9f5cf2249
commit
1f06898beb
2 changed files with 19 additions and 9 deletions
|
@ -540,7 +540,10 @@ export function DimensionEditor(
|
||||||
(yAxisConfig) => yAxisConfig.forAccessor === accessor
|
(yAxisConfig) => yAxisConfig.forAccessor === accessor
|
||||||
);
|
);
|
||||||
if (existingIndex !== -1) {
|
if (existingIndex !== -1) {
|
||||||
newYAxisConfigs[existingIndex].axisMode = newMode;
|
newYAxisConfigs[existingIndex] = {
|
||||||
|
...newYAxisConfigs[existingIndex],
|
||||||
|
axisMode: newMode,
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
newYAxisConfigs.push({
|
newYAxisConfigs.push({
|
||||||
forAccessor: accessor,
|
forAccessor: accessor,
|
||||||
|
@ -625,9 +628,9 @@ const ColorPicker = ({
|
||||||
const existingIndex = newYConfigs.findIndex((yConfig) => yConfig.forAccessor === accessor);
|
const existingIndex = newYConfigs.findIndex((yConfig) => yConfig.forAccessor === accessor);
|
||||||
if (existingIndex !== -1) {
|
if (existingIndex !== -1) {
|
||||||
if (text === '') {
|
if (text === '') {
|
||||||
delete newYConfigs[existingIndex].color;
|
newYConfigs[existingIndex] = { ...newYConfigs[existingIndex], color: undefined };
|
||||||
} else {
|
} else {
|
||||||
newYConfigs[existingIndex].color = output.hex;
|
newYConfigs[existingIndex] = { ...newYConfigs[existingIndex], color: output.hex };
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newYConfigs.push({
|
newYConfigs.push({
|
||||||
|
|
|
@ -198,7 +198,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||||
await testSubjects.missingOrFail('lnsXY_yDimensionPanel > lns-dimensionTrigger');
|
await testSubjects.missingOrFail('lnsXY_yDimensionPanel > lns-dimensionTrigger');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should allow creation of a multi-axis chart', async () => {
|
it('should allow creation of a multi-axis chart and switching multiple times', async () => {
|
||||||
await PageObjects.visualize.navigateToNewVisualization();
|
await PageObjects.visualize.navigateToNewVisualization();
|
||||||
await PageObjects.visualize.clickVisType('lens');
|
await PageObjects.visualize.clickVisType('lens');
|
||||||
await elasticChart.setNewChartUiDebugFlag(true);
|
await elasticChart.setNewChartUiDebugFlag(true);
|
||||||
|
@ -225,14 +225,21 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||||
});
|
});
|
||||||
|
|
||||||
await PageObjects.lens.changeAxisSide('right');
|
await PageObjects.lens.changeAxisSide('right');
|
||||||
|
|
||||||
await PageObjects.lens.closeDimensionEditor();
|
|
||||||
|
|
||||||
await PageObjects.lens.waitForVisualization();
|
await PageObjects.lens.waitForVisualization();
|
||||||
|
let data = await PageObjects.lens.getCurrentChartDebugState();
|
||||||
const data = await PageObjects.lens.getCurrentChartDebugState();
|
|
||||||
expect(data?.axes?.y.length).to.eql(2);
|
expect(data?.axes?.y.length).to.eql(2);
|
||||||
expect(data?.axes?.y.some(({ position }) => position === 'right')).to.eql(true);
|
expect(data?.axes?.y.some(({ position }) => position === 'right')).to.eql(true);
|
||||||
|
|
||||||
|
await PageObjects.lens.changeAxisSide('left');
|
||||||
|
await PageObjects.lens.waitForVisualization();
|
||||||
|
data = await PageObjects.lens.getCurrentChartDebugState();
|
||||||
|
expect(data?.axes?.y.length).to.eql(1);
|
||||||
|
expect(data?.axes?.y.some(({ position }) => position === 'right')).to.eql(false);
|
||||||
|
|
||||||
|
await PageObjects.lens.changeAxisSide('right');
|
||||||
|
await PageObjects.lens.waitForVisualization();
|
||||||
|
|
||||||
|
await PageObjects.lens.closeDimensionEditor();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show value labels on bar charts when enabled', async () => {
|
it('should show value labels on bar charts when enabled', async () => {
|
||||||
|
|
Loading…
Reference in a new issue