Skip to content

"Open in new tab" relationship values are overwritten when user first enters a different relationship value #29690

Description

@skorasaurus

While reviewing PR #29664 ; I encountered this but it also applicable in Gutenberg.

Description

This is a bit of an edge case, but when a user first enters a valid 'rel' value in the "link rel" field (which is ambiguously named, visit this issue for more information on the ambiguity; and then toggles, the value of the is overwritten.

Step-by-step reproduction instructions

Please list the steps needed to reproduce the bug. For example:

  1. create new page
  2. create a button
  3. enter a link
  4. go to the advanced settings or the link settings of that block's sidebar, enter in a valid 'rel' value. I typed in external in my test cases.
  5. go back to the button, enable the toggle for the "open in new tab"
  6. click publish

Expected behaviour

rel value to the button's link to be noreferrer noopener external

Actual behaviour

the rel's value of the button's link was 'rel="external noopener"

Screenshots or screen recording

The screen recording shows the intended behavior if you

2021-03-08.mp4

I've verified that this behavior occurs both when the user clicks the 'open in new tab' toggle in the sidebar or if they click the toggle in the link UI.

The more important part is that the rel field in the sidebar has values entered in it BEFORE the toggle is clicked.

I am NOT able to reproduce this if you first click the 'open in new tab' toggle and then add an additional rel value into the 'link rel' field (likely because 'external and noopener' are added first).

Also worth noting:

there is a PR to remove the noreferrer value - #26968
so this issue may be moot; I haven't tried if you enter multiple ref value first.
There's an issue to overhaul the entire link UI

WordPress information

  • WordPress version: 5.6.0
  • Gutenberg version: 10.1.1
  • Are all plugins except Gutenberg deactivated? yes
  • Are you using a default theme (e.g. Twenty Twenty-One)? tested on twentytwenty and twentytwentyone.

Device information

  • Device:
  • Operating system:
  • Browser:

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] ButtonsAffects the Buttons Block[Priority] LowUsed to indicate that the issue at hand isn't a top priority to address and can be handled later[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions