diff --git a/CHANGELOG.md b/CHANGELOG.md index 18b7743..f89f34b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- After **Update citations**, the "Citation style changed" snackbar is dismissed, so it no longer sits beside the result still saying citations use the old style. + ## [1.19.0] - 2026-11-06 ### Added diff --git a/docs/current-metrics.md b/docs/current-metrics.md index ed6b6ff..ee71ce6 100644 --- a/docs/current-metrics.md +++ b/docs/current-metrics.md @@ -13,7 +13,7 @@ Source and LOC figures last verified: **2026-10-06** against the heading-level b |---|---|---| | Main plugin file (`bibliography-builder.php`) | **823** | `wc -l bibliography-builder.php` | | All first-party PHP (excl. vendor, tests, scripts, playground, packages, output, node_modules, generated `build/`) | **18334** | `find . -name '*.php' -not -path './vendor/*' -not -path './node_modules/*' -not -path './tests/*' -not -path './packages/*' -not -path './scripts/*' -not -path './playground/*' -not -path './output/*' -not -path './build/*' -print0 \| xargs -0 wc -l \| tail -1` | -| JS source (`src/`, excl. `*.test.js`) | **16210** | `find ./src -name '*.js' -not -name '*.test.js' -print0 \| xargs -0 wc -l \| tail -1` | +| JS source (`src/`, excl. `*.test.js`) | **16216** | `find ./src -name '*.js' -not -name '*.test.js' -print0 \| xargs -0 wc -l \| tail -1` | | Shipped frontend runtime (`build/view.js`, minified) | **3,183 bytes** | `npm run build` then `wc -c < build/view.js` | The only PHP that executes at runtime on a visitor request path is `bibliography-builder.php` diff --git a/src/hooks/use-citation-updates.js b/src/hooks/use-citation-updates.js index 3e6f72b..840fbd3 100644 --- a/src/hooks/use-citation-updates.js +++ b/src/hooks/use-citation-updates.js @@ -108,6 +108,12 @@ export function useCitationUpdates( clientId ) { ); } + // The style-change snackbar (edit.js) says citations still use the + // old style; once they are updated it is out of date, so drop it. + registry + .dispatch( noticesStore ) + .removeNotice( `borges-citation-style-${ clientId }` ); + registry .dispatch( noticesStore ) .createNotice( diff --git a/src/hooks/use-citation-updates.test.js b/src/hooks/use-citation-updates.test.js index dbde2a5..b175378 100644 --- a/src/hooks/use-citation-updates.test.js +++ b/src/hooks/use-citation-updates.test.js @@ -7,6 +7,7 @@ import { const mockUpdateBlockAttributes = jest.fn(); const mockCreateNotice = jest.fn(); +const mockRemoveNotice = jest.fn(); let mockBlocks = []; jest.mock( '@wordpress/data', () => ( { @@ -14,7 +15,10 @@ jest.mock( '@wordpress/data', () => ( { select: () => ( { getBlocks: () => mockBlocks } ), dispatch: ( store ) => store === 'core/notices' - ? { createNotice: mockCreateNotice } + ? { + createNotice: mockCreateNotice, + removeNotice: mockRemoveNotice, + } : { updateBlockAttributes: mockUpdateBlockAttributes }, } ), } ) ); @@ -61,6 +65,7 @@ describe( 'useCitationUpdates', () => { beforeEach( () => { mockUpdateBlockAttributes.mockClear(); mockCreateNotice.mockClear(); + mockRemoveNotice.mockClear(); mockBlocks = [ { clientId: 'p1', @@ -124,4 +129,17 @@ describe( 'useCitationUpdates', () => { expect.anything() ); } ); + + it( 'dismisses the style-change snackbar once citations are updated', () => { + const { result } = renderHook( () => useCitationUpdates( 'bib' ) ); + + result.current.updateCitations( false ); + + expect( mockRemoveNotice ).toHaveBeenCalledWith( + 'borges-citation-style-bib' + ); + expect( mockRemoveNotice.mock.invocationCallOrder[ 0 ] ).toBeLessThan( + mockCreateNotice.mock.invocationCallOrder[ 0 ] + ); + } ); } );