diff --git a/src/ui/newsPanel.js b/src/ui/newsPanel.js index b32d1d899..a63f77739 100644 --- a/src/ui/newsPanel.js +++ b/src/ui/newsPanel.js @@ -33,7 +33,10 @@ export function createNewsPanel({ container, setLayerParams = () => {} } = {}) { renderVue(h(NewsFeed, { view, onParams }), container); const hidden = !view; if (panel) set(panel, 'hidden', hidden); - if (count) set(count, 'textContent', String(view?.items.length ?? 0)); + // The count is the shown section's: Local's list, else the feed. + const shown = + view?.filters?.section === 'local' ? view.inView?.items : view?.items; + if (count) set(count, 'textContent', String(shown?.length ?? 0)); if (!hidden && panel && !appearedPanels.has(panel)) { appearedPanels.add(panel); // First appearance opens the panel unless a stored or shared collapse diff --git a/src/ui/newsPanel.test.mjs b/src/ui/newsPanel.test.mjs index 920e25c84..a3dd2196f 100644 --- a/src/ui/newsPanel.test.mjs +++ b/src/ui/newsPanel.test.mjs @@ -228,6 +228,11 @@ test('filters, the Local section and empty or failed reads', () => { assert.equal(panel.querySelector('[data-chip-id="ua-ru-war"]'), null); assert.equal(panel.querySelector('select[aria-label="Severity"]'), null); assert.equal(panel.querySelector('[aria-label="Latest news"]'), null); + assert.equal(document.getElementById('news-panel-count').textContent, '0'); + news.update( + localView({ active: true, items: [feedCardView(report('near'), NOW)] }), + ); + assert.equal(document.getElementById('news-panel-count').textContent, '1'); news.update(localView({ active: true })); assert.match( panel.querySelector('[aria-label="Local"]').textContent,