Skip to content

Commit 0e8ccc6

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
RPP: deal with clearing annotations bug when count === 0
Fixed: 395482394 Change-Id: I8b63f04e88e4f57464dc69217a9d6f47ee5671db Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6244428 Auto-Submit: Jack Franklin <[email protected]> Reviewed-by: Kateryna Prokopenko <[email protected]> Commit-Queue: Kateryna Prokopenko <[email protected]> Commit-Queue: Jack Franklin <[email protected]>
1 parent 938aa95 commit 0e8ccc6

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

front_end/panels/timeline/components/Sidebar.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as Trace from '../../../models/trace/trace.js';
66
import {raf, renderElementIntoDOM} from '../../../testing/DOMHelpers.js';
77
import {describeWithEnvironment} from '../../../testing/EnvironmentHelpers.js';
88
import {TraceLoader} from '../../../testing/TraceLoader.js';
9+
import * as RenderCoordinator from '../../../ui/components/render_coordinator/render_coordinator.js';
910

1011
import * as Components from './components.js';
1112

@@ -119,4 +120,27 @@ describeWithEnvironment('Sidebar', () => {
119120
const countBadge = annotationsTab.querySelector<HTMLElement>('.badge');
120121
assert.strictEqual(countBadge?.innerText, '1');
121122
});
123+
124+
it('removes the annotations badge when the user deletes the final annotation', async function() {
125+
const {parsedTrace, metadata} = await TraceLoader.traceEngine(this, 'web-dev-with-commit.json.gz');
126+
const entryLabelAnnotation: Trace.Types.File.Annotation = {
127+
type: 'ENTRY_LABEL',
128+
entry: parsedTrace.Renderer.allTraceEntries[0], // random event, doesn't matter
129+
label: 'hello world',
130+
};
131+
132+
const sidebar = await renderSidebar(parsedTrace, metadata, null);
133+
sidebar.setAnnotations([entryLabelAnnotation], new Map());
134+
await RenderCoordinator.done();
135+
const tabbedPane = sidebar.element.querySelector('.tabbed-pane')?.shadowRoot;
136+
assert.isOk(tabbedPane);
137+
const annotationsTab = tabbedPane.querySelector('#tab-annotations');
138+
assert.isOk(annotationsTab);
139+
const countBadge = annotationsTab.querySelector<HTMLElement>('.badge');
140+
assert.strictEqual(countBadge?.innerText, '1');
141+
142+
sidebar.setAnnotations([], new Map()); // delete the annotations
143+
const updatedCountBadge = annotationsTab.querySelector<HTMLElement>('.badge');
144+
assert.isNull(updatedCountBadge); // No badge is shown when the count is 0.
145+
});
122146
});

front_end/panels/timeline/components/Sidebar.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ export class SidebarWidget extends UI.Widget.VBox {
103103

104104
#updateAnnotationsCountBadge(): void {
105105
const annotations = this.#annotationsView.deduplicatedAnnotations();
106-
if (annotations.length) {
107-
this.#tabbedPane.setBadge('annotations', annotations.length.toString());
108-
}
106+
this.#tabbedPane.setBadge('annotations', annotations.length > 0 ? annotations.length.toString() : null);
109107
}
110108

111109
setParsedTrace(parsedTrace: Trace.Handlers.Types.ParsedTrace|null, metadata: Trace.Types.File.MetaData|null): void {

0 commit comments

Comments
 (0)