mirror of
https://github.com/nasa/openmct.git
synced 2025-02-20 01:16:46 +00:00
fix(overlay plot): legend updates correctly when removing element via remove action (#7531)
* fix: remove duplicate listeners * fix: if no series found, don't splice * test(e2e): update legend a11y and add test
This commit is contained in:
parent
0bdd0963a4
commit
39ab81c3d0
@ -356,6 +356,10 @@ test.describe('Overlay Plot', () => {
|
||||
type: 'Sine Wave Generator',
|
||||
parent: overlayPlot.uuid
|
||||
});
|
||||
const swgB = await createDomainObjectWithDefaults(page, {
|
||||
type: 'Sine Wave Generator',
|
||||
parent: overlayPlot.uuid
|
||||
});
|
||||
|
||||
await page.goto(overlayPlot.url);
|
||||
// Wait for plot series data to load and be drawn
|
||||
@ -370,6 +374,23 @@ test.describe('Overlay Plot', () => {
|
||||
await page.getByRole('menuitem', { name: 'Remove' }).click();
|
||||
await page.getByRole('button', { name: 'OK', exact: true }).click();
|
||||
await expect(swgAElementsPoolItem).toBeHidden();
|
||||
|
||||
await page.getByRole('button', { name: 'Save' }).click();
|
||||
await page.getByRole('listitem', { name: 'Save and Finish Editing' }).click();
|
||||
|
||||
test.info().annotations.push({
|
||||
type: 'issue',
|
||||
description: 'https://github.com/nasa/openmct/issues/7530'
|
||||
});
|
||||
await test.step('Verify that the legend is correct after removing a series', async () => {
|
||||
await page.getByLabel('Plot Canvas').hover();
|
||||
await page.mouse.move(50, 0, {
|
||||
steps: 10
|
||||
});
|
||||
await expect(page.getByLabel('Plot Legend Item')).toHaveCount(1);
|
||||
await expect(page.getByLabel(`Plot Legend Item for ${swgA.name}`)).toBeHidden();
|
||||
await expect(page.getByLabel(`Plot Legend Item for ${swgB.name}`)).toBeVisible();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -165,7 +165,6 @@ export default {
|
||||
this.registerListeners(this.config);
|
||||
}
|
||||
this.listenTo(this.config.legend, 'change:expandByDefault', this.changeExpandDefault, this);
|
||||
this.initialize();
|
||||
},
|
||||
mounted() {
|
||||
this.loaded = true;
|
||||
@ -182,16 +181,6 @@ export default {
|
||||
this.stopListening();
|
||||
},
|
||||
methods: {
|
||||
initialize() {
|
||||
if (this.domainObject.type === 'telemetry.plot.stacked') {
|
||||
this.objectComposition = this.openmct.composition.get(this.domainObject);
|
||||
this.objectComposition.on('add', this.addTelemetryObject);
|
||||
this.objectComposition.on('remove', this.removeTelemetryObject);
|
||||
this.objectComposition.load();
|
||||
} else {
|
||||
this.registerListeners(this.config);
|
||||
}
|
||||
},
|
||||
changeExpandDefault() {
|
||||
this.isLegendExpanded = this.config.legend.model.expandByDefault;
|
||||
this.legend.set('expanded', this.isLegendExpanded);
|
||||
|
@ -22,7 +22,7 @@
|
||||
<template>
|
||||
<div
|
||||
class="plot-legend-item"
|
||||
:aria-label="`Plot Legend Item for ${domainObject?.name}`"
|
||||
:aria-label="`Plot Legend Item for ${seriesName}`"
|
||||
:class="{
|
||||
'is-stale': isStale,
|
||||
'is-status--missing': isMissing
|
||||
@ -36,9 +36,8 @@
|
||||
@mouseover.ctrl="showToolTip"
|
||||
@mouseleave="hideToolTip"
|
||||
>
|
||||
<span class="plot-series-color-swatch" :style="{ 'background-color': colorAsHexString }">
|
||||
</span>
|
||||
<span class="is-status__indicator" title="This item is missing or suspect"></span>
|
||||
<span class="plot-series-color-swatch" :style="{ 'background-color': colorAsHexString }" />
|
||||
<span class="is-status__indicator" title="This item is missing or suspect" />
|
||||
<span class="plot-series-name">{{ nameWithUnit }}</span>
|
||||
</div>
|
||||
<div
|
||||
@ -89,6 +88,7 @@ export default {
|
||||
isMissing: false,
|
||||
colorAsHexString: '',
|
||||
nameWithUnit: '',
|
||||
seriesName: '',
|
||||
formattedYValue: '',
|
||||
formattedXValue: '',
|
||||
mctLimitStateClass: '',
|
||||
@ -206,6 +206,9 @@ export default {
|
||||
const seriesIndexToRemove = this.seriesModels.findIndex(
|
||||
(series) => series.keyString === seriesToRemove.keyString
|
||||
);
|
||||
if (seriesIndexToRemove === -1) {
|
||||
return;
|
||||
}
|
||||
this.seriesModels.splice(seriesIndexToRemove, 1);
|
||||
},
|
||||
getSeries(keyStringToFind) {
|
||||
@ -220,6 +223,7 @@ export default {
|
||||
|
||||
this.isMissing = seriesObject.domainObject.status === 'missing';
|
||||
this.colorAsHexString = seriesObject.get('color').asHexString();
|
||||
this.seriesName = seriesObject.domainObject.name;
|
||||
this.nameWithUnit = seriesObject.nameWithUnit();
|
||||
|
||||
const closest = seriesObject.closest;
|
||||
|
Loading…
x
Reference in New Issue
Block a user