Skip to content

fix(rich-text-editor): DP-179947 use URL as display text when inserting link without text#1202

Merged
Brad Paugh (braddialpad) merged 2 commits intostagingfrom
DP-179947
Apr 17, 2026
Merged

fix(rich-text-editor): DP-179947 use URL as display text when inserting link without text#1202
Brad Paugh (braddialpad) merged 2 commits intostagingfrom
DP-179947

Conversation

@braddialpad
Copy link
Copy Markdown
Contributor

@braddialpad Brad Paugh (braddialpad) commented Apr 15, 2026

Description

JIRA Link: https://dialpad.atlassian.net/browse/DP-179947

When a user inserts a link in the rich text editor without providing display text, the link is now visible in the editor using the URL itself as the display text.

Summary of changes requested

  • Fix setLink in DtRichTextEditor to fall back to the URL when display text is empty
  • Add tests covering both the display-text-provided and display-text-empty cases

Technical Details

Root cause: setLink(linkInput, linkText, ...) called insertContent(linkText) followed by setTextSelection({ from, to: from + linkText.length }). When linkText was "", this inserted nothing and created a zero-width selection, so the subsequent setLink() mark command had no range to apply to — leaving the editor with no visible link node.

Fix: packages/dialtone-vue/components/rich_text_editor/rich_text_editor.vue — introduce const displayText = linkText || linkInput and use it for both insertContent and setTextSelection, so the URL is used as the visible text when no display text is provided.

Tests: Added two cases to rich_text_editor.test.js under a new setLink method describe block — one for when display text is provided, one for when it is empty.

Use the URL as visible link text when no display text is provided to prevent zero-width selections. setLink now derives displayText = linkText || linkInput and uses it for insertContent and selection. Added tests covering both non-empty and empty display-text link insertion.

…ng link without text

When setLink is called with an empty display text, insert the href URL
as the visible text instead of inserting an empty string, which left the
editor with a zero-width selection and no visible link node.
@github-actions
Copy link
Copy Markdown
Contributor

Please add either the visual-test-ready or no-visual-test label to this PR depending on whether you want to run visual tests or not.
It is recommended to run visual tests if your PR changes any UI. ‼️

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 4cd6a87b-ae21-4a10-b3b3-a4b342fa0900

📥 Commits

Reviewing files that changed from the base of the PR and between ad6c571 and 56d8b8b.

📒 Files selected for processing (1)
  • packages/dialtone-vue/components/rich_text_editor/rich_text_editor.test.js
✅ Files skipped from review due to trivial changes (1)
  • packages/dialtone-vue/components/rich_text_editor/rich_text_editor.test.js

Walkthrough

Updates setLink to use the computed displayText (fallback linkInput when linkText is empty) for inserted link text and selection range; adds tests exercising setLink with explicit display text and empty display text to verify generated HTML link text and href.

Changes

Cohort / File(s) Summary
Tests
packages/dialtone-vue/components/rich_text_editor/rich_text_editor.test.js
Added describe('setLink method') tests that call wrapper.vm.setLink(...) with two cases (display text provided, display text empty) and assert resulting HTML includes correct link text and href.
Implementation
packages/dialtone-vue/components/rich_text_editor/rich_text_editor.vue
Changed setLink to compute `displayText = linkText

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch DP-179947

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.42.1)
packages/dialtone-vue/components/rich_text_editor/rich_text_editor.test.js

Comment @coderabbitai help to get the list of available commands and usage tips.

@braddialpad Brad Paugh (braddialpad) added the visual-test-ready Add this tag when the PR is ready for visual test, to trigger GHA visual tests label Apr 15, 2026
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/dialtone-vue/components/rich_text_editor/rich_text_editor.test.js`:
- Around line 1647-1663: Refactor the two tests around setLink/getOutput into
parameterized single-assertion cases using it.each: call wrapper.vm.setLink(url,
displayText, linkOptions, supportedProtocols, defaultPrefix) and await
wrapper.vm.$nextTick() inside each row, then assert only one expected string per
case against wrapper.vm.getOutput(); consolidate the two scenarios (display text
provided vs empty) into a table of [url, displayText, expectedSubstring] and
replace the duplicate test flow with a single it.each block that checks the one
expectedSubstring per row (referencing setLink and getOutput to locate the
change).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: b1b73448-281d-4838-a123-ca77032d319e

📥 Commits

Reviewing files that changed from the base of the PR and between 9971fc0 and ad6c571.

📒 Files selected for processing (2)
  • packages/dialtone-vue/components/rich_text_editor/rich_text_editor.test.js
  • packages/dialtone-vue/components/rich_text_editor/rich_text_editor.vue

Comment thread packages/dialtone-vue/components/rich_text_editor/rich_text_editor.test.js Outdated
@github-actions
Copy link
Copy Markdown
Contributor

✔️ Deploy previews ready!
😎 Dialtone documentation preview: https://dialtone.dialpad.com/deploy-previews/pr-1202/
😎 Dialtone-vue preview: https://dialtone.dialpad.com/vue/deploy-previews/pr-1202/

@braddialpad Brad Paugh (braddialpad) merged commit 30f2504 into staging Apr 17, 2026
26 checks passed
@braddialpad Brad Paugh (braddialpad) deleted the DP-179947 branch April 17, 2026 19:51
Brad Paugh (braddialpad) pushed a commit that referenced this pull request Apr 17, 2026
## [3.219.1](dialtone-vue/v3.219.0...dialtone-vue/v3.219.1) (2026-04-17)

### Bug Fixes

* **Rich Text Editor:** DP-179947 use URL as display text when inserting link without text ([#1202](#1202)) ([30f2504](30f2504))
Brad Paugh (braddialpad) pushed a commit that referenced this pull request Apr 17, 2026
# [9.180.0](dialtone/v9.179.0...dialtone/v9.180.0) (2026-04-17)

### Bug Fixes

* **Rich Text Editor:** DP-179947 use URL as display text when inserting link without text ([#1202](#1202)) ([30f2504](30f2504))

### Documentation

* **Modal:** NO-JIRA fix code examples ([#1207](#1207)) ([aedd4a1](aedd4a1))

### Features

* **Eslint Plugin Dialtone:** DLT-3314 add deprecated-dialtone-component rule ([#1200](#1200)) ([c73b7ee](c73b7ee))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

visual-test-ready Add this tag when the PR is ready for visual test, to trigger GHA visual tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants