Skip to content

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

Open
prathmeshyelne wants to merge 2 commits 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 2 commits into
codex-team:nextfrom
prathmeshyelne:bug-unlink

Conversation

@prathmeshyelne

@prathmeshyelne prathmeshyelne commented Jun 9, 2026

Copy link
Copy Markdown

Problem

In v2.31.6, three 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.
  3. Formatting tools removed existing links — applying Bold, Italic, Marker, or Inline Code to linked text could remove or break the existing anchor element, causing the link to be lost.

The unlink regressions 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, preventing unlink() from being executed.

Additionally, inline formatting tools did not consistently preserve anchor elements when modifying linked content.

Solution

  • Remove the !this.inputOpened guard in surround() so that clicking the Link tool or pressing Cmd/Ctrl+K while inside an anchor always performs an unlink operation, restoring the behavior from v2.29.1.
  • Add dynamic tooltip support through 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.
  • Preserve anchor elements when applying:
    • Bold
    • Italic
    • Marker
    • Inline Code
  • Ensure inline formatting can be applied to linked text without removing the underlying anchor element or its attributes.

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 support dynamic button titles
src/components/modules/toolbar/inline.ts Read instance.getTitle?.() after checkState() to update popover hint text dynamically
src/components/utils/popover/popover-inline.ts Preserve existing anchor elements when applying Bold, Italic, Marker, and Inline Code formatting

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 and "Link" otherwise
  • Applying Bold preserves existing links
  • Applying Italic preserves existing links
  • Applying Marker preserves existing links
  • Applying Inline Code preserves existing links
  • Existing link attributes remain intact after formatting operations

Fix Video :

Screen.Recording.2026-06-13.at.5.27.48.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
…rigger

- Remove the call to nestedPopoverTriggerItem?.handleClick() when switching
  to another tool, as it caused unintended side effects (e.g., link tool
  modifying selection when switching away from it).
- Keep only the destroyNestedPopoverIfExists() call to properly clean up
  the nested popover when switching tools.
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