Skip to content

fix(inline-tool-link): restore unlink behavior and add dynamic tooltip with keyboard Shortcut#3008

Open
prathmeshyelne wants to merge 1 commit into
codex-team:nextfrom
prathmeshyelne:bug-unlink
Open

fix(inline-tool-link): restore unlink behavior and add dynamic tooltip with keyboard Shortcut#3008
prathmeshyelne wants to merge 1 commit into
codex-team:nextfrom
prathmeshyelne:bug-unlink

Conversation

@prathmeshyelne

Copy link
Copy Markdown

Problem

In v2.31.6, two regressions appeared in the Link Inline Tool:

  1. Unlink button does not work — clicking the Link tool icon while the selection is inside an anchor does nothing. The anchor is never removed.
  2. Cmd/Ctrl+K shortcut cannot remove links — pressing ⌘+K (Mac) or Ctrl+K (Win/Linux) while the selection is inside an existing link also fails to unlink.

Both were introduced by commit 9f942ca which added a !this.inputOpened guard around the unlink logic. Because checkState() always opens the link input when an anchor is detected, the guard was never satisfied, so unlink() was never called.

Solution

  • Remove the !this.inputOpened guard in surround() so that clicking the Link tool or pressing Cmd/Ctrl+K while inside an anchor always unlinks, restoring the v2.29.1 behavior.
  • Add dynamic tooltip via a new getTitle() method on LinkInlineTool:
    • When selection is inside a link → tooltip shows "Unlink"
    • Otherwise → tooltip shows "Link"
  • Update the Inline Toolbar to read dynamic titles from tool instances so the popover hint reflects the current state.

Changes

File Change
src/components/inline-tools/inline-tool-link.ts Fix surround() to always unlink when parentAnchor exists; add getTitle(); update render() and checkState() to set dynamic button.title
src/components/modules/toolbar/inline.ts Read instance.getTitle?.() after checkState() to populate the popover hint title

Acceptance criteria

  • Existing links are detected correctly
  • Cmd+K (Mac) toggles link creation and removal
  • Ctrl+K (Windows/Linux) toggles link creation and removal
  • Link dialog enters edit mode when a link is selected
  • Unlink button is visible and functional
  • Unlink removes the anchor tag while keeping text intact
  • Tooltip shows "Unlink" when inside a link, "Link" otherwise

Fix Video :

Screen.Recording.2026-06-09.at.10.30.24.PM.mov

Closes #3005

- Remove the !this.inputOpened guard that prevented unlinking when
the link input was already open (which it always is when an anchor
is detected via checkState).
- Add getTitle() to LinkInlineTool for dynamic tooltip: shows 'Unlink'
when selection is inside a link, 'Link' otherwise.
- Update inline toolbar to read dynamic title from tool instances.

Closes codex-team#3005
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Link cannot be removed

1 participant