You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(theme-classic): check announcementBar id in inline dismiss script - #13097
getAnnouncementBarInlineScript() previously only checked docusaurus.announcement.dismiss === 'true' and ignored docusaurus.announcement.id. When a site updated themeConfig.announcementBar.id, users who had dismissed the previous announcement still received data-announcement-bar-initially-dismissed="true" on first load, keeping the newly rendered bar hidden via CSS until a second page load.
This passes announcementBar into getAnnouncementBarInlineScript() and only marks the bar initially dismissed when both docusaurus.announcement.dismiss === 'true' and docusaurus.announcement.id matches the configured announcementBar.id (safely JSON-escaped for inline <script>).
Announcement bar dismissal is now tied to the current announcement. If the announcement changes, a previously saved dismissal won’t hide the new announcement; matching announcements remain dismissed across visits.
No actionable comments were generated in the recent review.
Walkthrough
The announcement-bar inline script now checks whether the stored announcement ID matches the configured ID before marking the bar as initially dismissed. The caller passes the announcement-bar configuration, and tests cover matching and changed IDs, namespaced storage, and special characters.
Changes: Announcement bar visibility
Layer / File(s)
Summary
Check the configured announcement ID packages/docusaurus-theme-classic/src/inlineScripts.ts, packages/docusaurus-theme-classic/src/index.ts, packages/docusaurus-theme-classic/src/__tests__/inlineScripts.test.ts
The inline script marks the bar as dismissed only when the stored dismissal flag is true and the stored announcement ID matches the configured ID. The caller passes the announcement-bar configuration. Tests cover matching and changed IDs, namespaced storage, and special characters.
meta/docusaurus#12838: Passes the configured announcement ID to the inline script and compares it with the stored ID.
meta/docusaurus#12842: Compares the stored ID with the configured ID before marking the bar as dismissed.
meta/docusaurus#12931: Passes the announcement configuration to the inline script and checks the stored ID.
Merge Risk: Minimal · up to b4416
This change makes a new announcement bar appear on first load after its configured id changes. The change is narrow and covered by tests, and no merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: the inline announcement-bar dismiss script now checks the stored announcement ID against the configured announcementBar id. The raw summary confirms that getAnnounceme…
Linked Issues check
[#12646] requires the inline script to stop hiding a new announcement bar for users who dismissed the previous one. At the reviewed head, `getAnnouncementBarInlineScript({announcementBar, siteStorage}…
Out of Scope Changes check
The whole-PR changes, as described by the supplied summary and confirmed in inlineScripts.ts at head, are limited to: (1) inlineScripts.ts, which adds the ID check to the dismissal logic; (2) `ind…
Full details: Title check
Explanation
The title names the main change: the inline announcement-bar dismiss script now checks the stored announcement ID against the configured announcementBar id. The raw summary confirms that getAnnouncementBarInlineScript now receives announcementBar and compares the stored ID with announcementBar.id, which matches the linked issue's goal of showing a new bar after its id changes. The title is specific and uses the conventional fix(scope) format.
Full details: Linked Issues check
Explanation
[#12646] requires the inline script to stop hiding a new announcement bar for users who dismissed the previous one. At the reviewed head, getAnnouncementBarInlineScript({announcementBar, siteStorage}) in packages/docusaurus-theme-classic/src/inlineScripts.ts builds isDismissed() as localStorage['docusaurus.announcement.dismiss'] === 'true' && localStorage['docusaurus.announcement.id'] === <JSON-encoded announcementBar.id>. The attribute data-announcement-bar-initially-dismissed is set from this result. When the stored ID is the old ID, the function returns false, so the CSS rule does not hide the new bar on first load. The ID is JSON-encoded with < replaced by \u003c, which keeps the inline script safe. The raw summary states that index.ts now passes announcementBar to this function. I read the head file directly, but I could not read the index.ts diff because the changed blobs were unavailable. That call-site change is therefore based on the supplied summary. The test file summary also reports tests for matching ID, differing ID, and special characters in the ID. I did not read those tests directly. The issue requirement is met by the inline script code at head.
Full details: Out of Scope Changes check
Explanation
The whole-PR changes, as described by the supplied summary and confirmed in inlineScripts.ts at head, are limited to: (1) inlineScripts.ts, which adds the ID check to the dismissal logic; (2) index.ts, which passes announcementBar to that function; and (3) inlineScripts.test.ts, which adds tests for this behavior. All of these directly implement or verify the [#12646] requirement. No unrelated change is reported. The index.ts diff and test file contents were not read directly because the diff was unavailable, so this verdict relies partly on the summary.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getAnnouncementBarInlineScript()previously only checkeddocusaurus.announcement.dismiss === 'true'and ignoreddocusaurus.announcement.id. When a site updatedthemeConfig.announcementBar.id, users who had dismissed the previous announcement still receiveddata-announcement-bar-initially-dismissed="true"on first load, keeping the newly rendered bar hidden via CSS until a second page load.This passes
announcementBarintogetAnnouncementBarInlineScript()and only marks the bar initially dismissed when bothdocusaurus.announcement.dismiss === 'true'anddocusaurus.announcement.idmatches the configuredannouncementBar.id(safely JSON-escaped for inline<script>).Fixes #12646
Summary by CodeRabbit