Skip to content

Commit 3a5014f

Browse files
committed
fix(LinkInlineTool): improve unlink behavior based on input state
1 parent 90d6dec commit 3a5014f

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

src/components/inline-tools/inline-tool-link.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,21 @@ export default class LinkInlineTool implements InlineTool {
172172
* Unlink icon pressed
173173
*/
174174
if (parentAnchor) {
175-
this.selection.expandToTag(parentAnchor);
176-
this.unlink();
177-
this.closeActions();
178-
this.checkState();
179-
this.toolbar.close();
175+
/**
176+
* If input is not opened, treat click as explicit unlink action.
177+
* If input is opened (e.g., programmatic close when switching tools), avoid unlinking.
178+
*/
179+
if (!this.inputOpened) {
180+
this.selection.expandToTag(parentAnchor);
181+
this.unlink();
182+
this.closeActions();
183+
this.checkState();
184+
this.toolbar.close();
185+
} else {
186+
/** Only close actions without clearing saved selection to preserve user state */
187+
this.closeActions(false);
188+
this.checkState();
189+
}
180190

181191
return;
182192
}

0 commit comments

Comments
 (0)