WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10k stars 4.02k forks source link

Bug - Class removed from links whenever they are edited #38878

Open frogdesk opened 2 years ago

frogdesk commented 2 years ago

Description

There is absolutely no way to add a class to a link in the current version of WordPress. Additionally, when saving a post, any classes added in previous versions are removed. These are critical bugs that should have been release blockers.

Step-by-step reproduction instructions

  1. Add a link
  2. Edit as HTML
  3. Give it a class
  4. Make any other changes to the link
  5. See that the class is removed

Screenshots, screen recording, code snippet

No response

Environment info

Current

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

talldan commented 2 years ago

Thanks for reaching out.

Switch to code view to add the class See that it is instantly removed

I couldn't reproduce this, when I tested the class stays and I can see it on my site, even after saving. Here's a screenshot of the HTML on the front-end of my test site: Screen Shot 2022-02-17 at 4 45 12 pm

I did notice the class is removed when editing and resubmitting the link, but not instantly. Were you testing using the paragraph block or a different block? Any additional info you can provide that might help?

talldan commented 2 years ago

I noticed there's been some previous discussion here about adding classes to links - https://github.com/WordPress/gutenberg/issues/13368.

github-actions[bot] commented 2 years ago

Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks.

frogdesk commented 2 years ago

The issue is that there is no way to add a class to a link in the current iteration of WordPress. I'm not sure how else to put it. You need to include this functionality. Pushing an update that removed it was a regression that broke websites all over the place.

What additional information are you after? You say you can't reproduce but then you described that in fact you could.

"I did notice the class is removed when editing and resubmitting the link"

That is a critical issue.

"Were you testing using the paragraph block or a different block?"

Which block you use is irrelevant. No blocks support putting a class on a link any more. The functionality was inexplicably removed.

But yes, the paragraph would be the most pertinent, as well as lists.

github-actions[bot] commented 2 years ago

Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks.

adamwoodnz commented 2 years ago

The issue is that there is no way to add a class to a link in the current iteration of WordPress.

I don't believe this is true. From my testing I too can add a class to a link using 'Edit as HTML', and it is able to be published.

The issue I see (and I think this is what @talldan found as well), is that if the link is edited afterwards (text or URL) the class is removed. As such I think it should be treated as a bug and in order to get this addressed the title should be changed to 'Link editing: HTML classname removed from link after editing'.

Please respond if you think otherwise.

frogdesk commented 2 years ago

That may be a bug, but it was also a completely ridiculous move to remove the ability to add this via the GUI.

adamwoodnz commented 2 years ago

We feel your frustration. A ticket tracking Link Control enhancement now covers this functionality: https://github.com/WordPress/gutenberg/issues/23011#issuecomment-1047766085

If you’d like this bug addressed separately I’d suggest updating the title and description to help our community maintainers work on it.

github-actions[bot] commented 2 years ago

Help us move this issue forward. This issue is being marked stale since it has no activity after 15 days of requesting more information. Please add info requested so we can help move the issue forward. Note: The triage policy is to close stale issues that need more info and no response after 2 weeks.

frogdesk commented 1 year ago

What more information do you need? It's not like it's hard to reproduce. Just stop removing the class from the link after the block is edited.

richtabor commented 1 year ago

via the GUI.

Hey @frogdesk, could you add a bit of context? I'm curious what your use case is here for adding classes to links.

frogdesk commented 1 year ago
ekazda commented 11 months ago

Modals is the biggest use case for me as well. Additionally there are times that I want a link to be highlighted or displayed differently than other links. Perhaps the font or color is different. Perhaps I want to add an icon. Regardless, CSS Classes is a pretty standard thing to want to apply to elements. It should have an interface where classes can be added to links. It exists elsewhere in wordpress (menus, image links, etc.). It needs to be added to text links as well.