restricting auto add anchor and idName to h2 in useEffect
This commit is contained in:
parent
9bc3efd77d
commit
f2087f77f9
|
|
@ -1 +1 @@
|
|||
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '9d27f8e8aa5dbd08d34f');
|
||||
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '93c893a8f74f7da180b4');
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ function Edit({
|
|||
setAttributes({
|
||||
idName: anchor
|
||||
});
|
||||
} else if (_utilities__WEBPACK_IMPORTED_MODULE_6__.cleanString && title) {
|
||||
} else if (_utilities__WEBPACK_IMPORTED_MODULE_6__.cleanString && title && headingLevel === "h2") {
|
||||
setAttributes({
|
||||
idName: "title-" + (0,_utilities__WEBPACK_IMPORTED_MODULE_6__.cleanString)(title)
|
||||
});
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -34,11 +34,10 @@ export default function Edit({
|
|||
...blockProps
|
||||
}) {
|
||||
const { title, headingLevel, hasIcon, iconName, idName, anchor } = attributes;
|
||||
|
||||
useEffect(() => {
|
||||
if (anchor) {
|
||||
setAttributes({ idName: anchor });
|
||||
} else if (cleanString && title) {
|
||||
} else if (cleanString && title && headingLevel === "h2") {
|
||||
setAttributes({
|
||||
idName: "title-" + cleanString(title),
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user