Repository navigation
fix(theme-classic): show announcement bar immediately when id changes #12846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,8 @@ const AnnouncementBarDismissStorage = createStorageSlot( | |
| 'docusaurus.announcement.dismiss', | ||
| ); | ||
| const IdStorage = createStorageSlot('docusaurus.announcement.id'); | ||
| const AnnouncementBarDismissDataAttribute = | ||
| 'data-announcement-bar-initially-dismissed'; | ||
|
|
||
| const isDismissedInStorage = () => | ||
| AnnouncementBarDismissStorage.get() === 'true'; | ||
|
|
@@ -78,6 +80,10 @@ function useContextValue(): ContextValue { | |
| } | ||
|
|
||
| if (isNewAnnouncement || !isDismissedInStorage()) { | ||
| document.documentElement.setAttribute( | ||
| AnnouncementBarDismissDataAttribute, | ||
| 'false', | ||
| ); | ||
|
Comment on lines
+83
to
+86
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| setClosed(false); | ||
| } | ||
| }, [announcementBar]); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: meta/docusaurus
Length of output: 398
Script executed:
Repository: meta/docusaurus
Length of output: 6741
Script executed:
Repository: meta/docusaurus
Length of output: 11826
Web query:
HTML Living Standard script data state end tag name "</script" inside script element JavaScript string literalResult:
Escape
<in the announcement ID before it enters the inline script.An announcement
idthat contains</script>ends the shared<script>element early. The theme and data-attribute scripts in that element then fail with a syntax error, and the leftover text renders in the page body.Suggested fix
Committable suggestion