Skip to content
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

Fix 13776: Format is already registered to handle class name #15072

Merged
merged 2 commits into from Apr 19, 2019

Conversation

@gziolo
Copy link
Member

commented Apr 19, 2019

Description

Fixes #13776.

Custom formats are logging this error:

`Format "${ formatTypeForBareElement.name }" is already registered to handle bare tag name "${ settings.tagName }".`
even when classNames were defined.

To Reproduce
Steps to reproduce the behavior:

  1. Format type with a class name A and tag name B gets registered.
  2. Another format type without any class name but the same tag name B gets registered.

Example format type to test with:

const { registerFormatType } = window.wp.richText;
const { RichTextToolbarButton } = window.wp.editor;

registerFormatType( 'wk/no-icon', {
	edit( { isActive } ) {
		return (
			<RichTextToolbarButton
				icon={ 'editor-link' }
				title={ 'Link ohne Icon' }
				isActive={ isActive }
				/>
		);
	},
  	tagName: 'a',
  	className: 'without-icon',
  	title: 'Link ohne Icon'
} );

Props to @pascalknecht for sharing.

Expected behavior
No error logs and all format types are properly registered. In the example provided core link should be there.

Screenshots
screen shot 2019-02-08 at 12 57 06 pm

@technote-space

This comment has been minimized.

Copy link
Contributor

commented Apr 19, 2019

This PR will also fix #13687

@ellatrix

This comment has been minimized.

Copy link
Member

commented Apr 19, 2019

Do you think this is something that should still be part of WordPress 5.2?

@ellatrix ellatrix force-pushed the fix/13776-format-bare-element branch from b009f87 to 0f9e0f9 Apr 19, 2019

@gziolo

This comment has been minimized.

Copy link
Member Author

commented Apr 19, 2019

Thanks @ellatrix, Good catch 👍

@gziolo gziolo added this to the 5.6 (Gutenberg) milestone Apr 19, 2019

@gziolo gziolo merged commit 48e06de into master Apr 19, 2019

1 check passed

Travis CI - Pull Request Build Passed
Details

@gziolo gziolo deleted the fix/13776-format-bare-element branch Apr 19, 2019

@gziolo

This comment has been minimized.

Copy link
Member Author

commented Apr 19, 2019

Do you think this is something that should still be part of WordPress 5.2?

Yes, it seems like a major inconvenience for plugin developers.

daniloercoli added a commit that referenced this pull request Apr 23, 2019
Merge branch 'master' of https://github.com/WordPress/gutenberg into …
…rnmobile/887-History-stack-is-not-empty-on-a-fresh-start-of-the-editor

* 'master' of https://github.com/WordPress/gutenberg:
  'string' misspelled as 'srting' (#15118)
  [Mobile] Improving accessibility on Post title (#15106)
  Fix 13776: Format is already registered to handle class name (#15072)
  Add wpDataSelect WordPress end 2 end test util (#15052)
  Block Editor: move selection state from RichText to the store (#14640)
  chore: Fix: Lint error that makes unit tests (and CI tests) fail. (#15073)
  Set ownProps.onFocus when context.onFocus is undefined. (#15069)
@pbiron

This comment has been minimized.

Copy link

commented Apr 28, 2019

Do you think this is something that should still be part of WordPress 5.2?

Yes, it seems like a major inconvenience for plugin developers.

Looks like this did not make it into 5.2. I'm using 5.2-RC1-45273 and I still get the error.

@aduth

This comment has been minimized.

Copy link
Member

commented Apr 30, 2019

Looks like this did not make it into 5.2. I'm using 5.2-RC1-45273 and I still get the error.

That's correct. It did not make it for 5.2 . I would assume it could be included in a subsequent minor release (5.2.x), which if I recall correctly from a previous #core dev chat should follow not-long-after the upcoming major release.

sbardian added a commit to sbardian/gutenberg that referenced this pull request Jul 29, 2019
Fix 13776: Format is already registered to handle class name (WordPre…
…ss#15072)

* Fix 13776: Format is already registered to handle class name

* Adjust test order
@swinggraphics

This comment has been minimized.

Copy link

commented Aug 28, 2019

There is an official tutorial in the documentation here with code. One expects that tagName could be set to something like "span" or "strong" or "a", but the "already registered to handle bare tag name" error comes up. How are we to add classes to existing elements, or create multiple custom formats using spans?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.