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

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

Open
frogdesk opened this issue Feb 17, 2022 · 13 comments
Open

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

frogdesk opened this issue Feb 17, 2022 · 13 comments
Labels
[Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) [Type] Bug An existing feature does not function as intended

Comments

@frogdesk
Copy link

frogdesk commented Feb 17, 2022

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
Copy link
Contributor

talldan commented Feb 17, 2022

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 talldan added [Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) Needs Testing Needs further testing to be confirmed. labels Feb 17, 2022
@getdave getdave changed the title Critical bug report: you cannot add a class to a link Cannot add a class to a link Feb 21, 2022
@talldan talldan added the [Status] Needs More Info Follow-up required in order to be actionable. label Feb 22, 2022
@talldan
Copy link
Contributor

talldan commented Feb 22, 2022

I noticed there's been some previous discussion here about adding classes to links - #13368.

@github-actions
Copy link

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.

@github-actions github-actions bot added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Mar 10, 2022
@frogdesk
Copy link
Author

frogdesk commented Mar 11, 2022

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 github-actions bot removed the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Mar 12, 2022
@github-actions
Copy link

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.

@github-actions github-actions bot added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Mar 27, 2022
@adamwoodnz
Copy link

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.

@adamwoodnz adamwoodnz added [Type] Bug An existing feature does not function as intended and removed [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. labels May 30, 2022
@frogdesk
Copy link
Author

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

@adamwoodnz adamwoodnz removed the Needs Testing Needs further testing to be confirmed. label May 30, 2022
@adamwoodnz
Copy link

We feel your frustration. A ticket tracking Link Control enhancement now covers this functionality: #23011 (comment)

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

@frogdesk frogdesk changed the title Cannot add a class to a link Bug - Class removed from links whenever they are edited May 31, 2022
@github-actions
Copy link

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.

@github-actions github-actions bot added the [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. label Jun 15, 2022
@adamwoodnz adamwoodnz removed [Status] Needs More Info Follow-up required in order to be actionable. [Status] Stale Gives the original author opportunity to update before closing. Can be reopened as needed. labels Jun 16, 2022
@frogdesk
Copy link
Author

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

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
Copy link
Author

frogdesk commented Jan 31, 2023

  • Modals
  • Styling purposes
  • Hooking into javascript
  • Smooth-scroll for on-page links

@ekazda
Copy link

ekazda commented Aug 14, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Link Editing Link components (LinkControl, URLInput) and integrations (RichText link formatting) [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

5 participants