diff --git a/src/components/inline-tools/inline-tool-link.ts b/src/components/inline-tools/inline-tool-link.ts index 9b413a564..999a30c4c 100644 --- a/src/components/inline-tools/inline-tool-link.ts +++ b/src/components/inline-tools/inline-tool-link.ts @@ -172,11 +172,21 @@ export default class LinkInlineTool implements InlineTool { * Unlink icon pressed */ if (parentAnchor) { - this.selection.expandToTag(parentAnchor); - this.unlink(); - this.closeActions(); - this.checkState(); - this.toolbar.close(); + /** + * If input is not opened, treat click as explicit unlink action. + * If input is opened (e.g., programmatic close when switching tools), avoid unlinking. + */ + if (!this.inputOpened) { + this.selection.expandToTag(parentAnchor); + this.unlink(); + this.closeActions(); + this.checkState(); + this.toolbar.close(); + } else { + /** Only close actions without clearing saved selection to preserve user state */ + this.closeActions(false); + this.checkState(); + } return; }