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

@gziolo gziolo 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

@gziolo gziolo added [Type] Bug An existing feature does not function as intended [Package] Format library /packages/format-library labels Apr 19, 2019
@gziolo gziolo self-assigned this Apr 19, 2019
@technote-space
Copy link
Contributor

This PR will also fix #13687

@ellatrix
Copy link
Member

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 Compare April 19, 2019 14:48
@gziolo
Copy link
Member Author

gziolo 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
@gziolo gziolo deleted the fix/13776-format-bare-element branch April 19, 2019 21:42
@gziolo
Copy link
Member Author

gziolo 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
…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
Copy link

pbiron 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
Copy link
Member

aduth 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.

@swinggraphics
Copy link

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
Labels
[Package] Format library /packages/format-library [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Format is already registered to handle class name error log
8 participants