Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/current-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
6 changes: 6 additions & 0 deletions src/hooks/use-citation-updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
20 changes: 19 additions & 1 deletion src/hooks/use-citation-updates.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ import {

const mockUpdateBlockAttributes = jest.fn();
const mockCreateNotice = jest.fn();
const mockRemoveNotice = jest.fn();
let mockBlocks = [];

jest.mock( '@wordpress/data', () => ( {
useRegistry: () => ( {
select: () => ( { getBlocks: () => mockBlocks } ),
dispatch: ( store ) =>
store === 'core/notices'
? { createNotice: mockCreateNotice }
? {
createNotice: mockCreateNotice,
removeNotice: mockRemoveNotice,
}
: { updateBlockAttributes: mockUpdateBlockAttributes },
} ),
} ) );
Expand Down Expand Up @@ -61,6 +65,7 @@ describe( 'useCitationUpdates', () => {
beforeEach( () => {
mockUpdateBlockAttributes.mockClear();
mockCreateNotice.mockClear();
mockRemoveNotice.mockClear();
mockBlocks = [
{
clientId: 'p1',
Expand Down Expand Up @@ -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 ]
);
} );
} );
Loading