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] Title is not getting updated after editing link #643

Closed
2 tasks done
olgaplaga opened this issue Nov 26, 2024 · 3 comments
Closed
2 tasks done

[BUG] Title is not getting updated after editing link #643

olgaplaga opened this issue Nov 26, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@olgaplaga
Copy link

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • I have read the documentation and cannot find an answer.

The closest bug is #443, but I am not sure if it is 100% the same issue.

Describe the bug

The link title node (the link's anchor text in the editor after adding the link) is not updated after the link edit.

Reproduction

Steps to reproduce the behavior:

  1. The link is created by typing the URL and title into the link dialog text fields.
  2. The link shows up in the editor.
  3. Select the created link in the editor, and click again on the add link button in the toolbar.
  4. Dialog opens again with two inputs prefilled correctly.
  5. Change the URL and Title in the dialog.
  6. Save the changes.
  7. The link node was correctly updated in the editor with a new URL.
  8. The link node was NOT correctly updated with the new Title.

Expected behavior

The link node displayed in the editor should be updated in the new title.

Screenshots

Screen.Recording.2024-11-26.at.10.59.30.mov

The recording comes from the https://mdxeditor.dev/editor/demo.

MacOs on Chrome.

Additional context
After investigating the code I came to the conclusion that the linkNode.setTitle(title) in updateLink$ method might not work correctly.

          () => {
            const linkNode = getLinkNodeInSelection(selection)
            if (!linkNode) {
              const node = $createLinkNode(url, { title })
              node.append($createTextNode(linkContent))
              $insertNodes([node])
              node.select()
            } else {
              linkNode.setURL(url)
              linkNode.setTitle(title)
            }
          },
          { discrete: true }
        )
@olgaplaga olgaplaga added the bug Something isn't working label Nov 26, 2024
@petyosi
Copy link
Contributor

petyosi commented Nov 26, 2024

@olgaplaga I can't really see the bug in the video you have recorded. You start with one, than change to two, and then two is displayed?

@olgaplaga
Copy link
Author

@petyosi thank you for the answer. The video shows that the link node inside the editor (blue highlighted "One") is not updated when I change the title in the dialog input.
First I changed it to "Two", I closed the dialog, and the link node in the editor still shows "One".
Then I changed to "three" - and the link note still shows "One".

Does it make it any clearer now?

@petyosi
Copy link
Contributor

petyosi commented Dec 4, 2024

Got it. The link title is used for the contents of the link inserted only initially. Afterwards, it won't change the contents - just the title attribute. There's an issue somewhere that discussed this in further depth.

@petyosi petyosi closed this as completed Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants