Skip to content

Commit 62e0e6f

Browse files
tyxlaMamadukajsnajdr
authored
Block Library: Cleanup unnecessary notice removal (#66409)
Co-authored-by: tyxla <[email protected]> Co-authored-by: Mamaduka <[email protected]> Co-authored-by: jsnajdr <[email protected]>
1 parent 0faf4c5 commit 62e0e6f

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

packages/block-library/src/latest-posts/edit.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,11 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
155155
);
156156

157157
// If a user clicks to a link prevent redirection and show a warning.
158-
const { createWarningNotice, removeNotice } = useDispatch( noticeStore );
159-
let noticeId;
158+
const { createWarningNotice } = useDispatch( noticeStore );
160159
const showRedirectionPreventedNotice = ( event ) => {
161160
event.preventDefault();
162-
// Remove previous warning if any, to show one at a time per block.
163-
removeNotice( noticeId );
164-
noticeId = `block-library/core/latest-posts/redirection-prevented/${ instanceId }`;
165161
createWarningNotice( __( 'Links are disabled in the editor.' ), {
166-
id: noticeId,
162+
id: `block-library/core/latest-posts/redirection-prevented/${ instanceId }`,
167163
type: 'snackbar',
168164
} );
169165
};

packages/block-library/src/table-of-contents/edit.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
ToolbarGroup,
1818
} from '@wordpress/components';
1919
import { useDispatch, useSelect } from '@wordpress/data';
20-
import { renderToString, useRef } from '@wordpress/element';
20+
import { renderToString } from '@wordpress/element';
2121
import { __ } from '@wordpress/i18n';
2222
import { useInstanceId } from '@wordpress/compose';
2323
import { store as noticeStore } from '@wordpress/notices';
@@ -58,15 +58,11 @@ export default function TableOfContentsEdit( {
5858
);
5959

6060
// If a user clicks to a link prevent redirection and show a warning.
61-
const { createWarningNotice, removeNotice } = useDispatch( noticeStore );
62-
const noticeIdRef = useRef();
61+
const { createWarningNotice } = useDispatch( noticeStore );
6362
const showRedirectionPreventedNotice = ( event ) => {
6463
event.preventDefault();
65-
// Remove previous warning if any, to show one at a time per block.
66-
removeNotice( noticeIdRef.current );
67-
noticeIdRef.current = `block-library/core/table-of-contents/redirection-prevented/${ instanceId }`;
6864
createWarningNotice( __( 'Links are disabled in the editor.' ), {
69-
id: noticeIdRef.current,
65+
id: `block-library/core/table-of-contents/redirection-prevented/${ instanceId }`,
7066
type: 'snackbar',
7167
} );
7268
};

0 commit comments

Comments
 (0)