Automattic / Automattic/wp-calypso

[Bug]: Editing hyperlink title replaces incorrect part of the string in parent block

Open
#68,340 1 comment 0 reactions 0 assignees View on GitHub
[Platform] Simple [Pri] Normal Blocks Bug Triaged
Dominant language
TypeScript
Stars
12.6k
Forks
2k
Avg merge
1d 18h
Merged PRs (30d)
509

Description

### Quick summary

If link's parent block contains the same text as the links title, and the text appears before the link, renaming the link title replaces the first match of the previous link title. See the gif below it is much easier to understand what I mean.

![Screen Capture on 2022-09-27 at 12-38-20](https://user-images.githubusercontent.com/2019970/192512156-712a4884-7fc5-4d92-a1d6-171c9490385d.gif)

### Steps to reproduce

1. Create a heading block with the following text: `New Post: Feature Image (Post)`
2. Make the second occurance of "Post" to be a hyperlink.
3. Go to edit the hyperlink. Change title of the link to `P2` and hit ENTER key on your keyboard
4. Notice how the title of the link did not change and instead the first occurance of `Post` was replaced with `P2` link.

### What you expected to happen

The original `Post` link to be displayed as `P2`

### What actually happened

The first occurance of `Post` word in the block's content was replaced with `P2` link, and the actual `Post` link that was edited remained intact.

### Browser

Google Chrome/Chromium

### Context

_No response_

### Platform (Simple, Atomic, or both?)

Simple

### Other notes

_No response_

### Reproducibility

Consistent

### Severity

All

### Available workarounds?

Yes, easy to implement

### Workaround details

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue in Google Chrome using the documented heading and hyperlink steps, then trace the hyperlink title editing flow in the TypeScript frontend; the issue names no file or test to start from. Done means renaming the second “Post” changes that link to “P2” without replacing the earlier matching text.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.