Skip to content

Commit

Permalink
Clear visible admin notices when switching from editing a snippet to …
Browse files Browse the repository at this point in the history
…creating a new snippet.
  • Loading branch information
sheabunge committed Nov 22, 2024
1 parent ccc6d6d commit a408f6f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/js/components/SnippetForm/page/PageHeading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useSnippetForm } from '../../../hooks/useSnippetForm'
const OPTIONS = window.CODE_SNIPPETS_EDIT

export const PageHeading: React.FC = () => {
const { snippet, updateSnippet } = useSnippetForm()
const { snippet, updateSnippet, setCurrentNotice } = useSnippetForm()

return (
<h1>
Expand All @@ -18,6 +18,7 @@ export const PageHeading: React.FC = () => {
<a href={window.CODE_SNIPPETS?.urls.addNew} className="page-title-action" onClick={event => {
event.preventDefault()
updateSnippet(() => createEmptySnippet())
setCurrentNotice(undefined)

window.document.title = window.document.title.replace(
__('Edit Snippet', 'code-snippets'),
Expand Down

0 comments on commit a408f6f

Please sign in to comment.