Skip to content

ExternalLink: Keep the new-tab indicator with the link text - #84845

Closed
mirka wants to merge 2 commits into
trunkfrom
fix-external-link-new-tab-wrapping
Closed

mirka wants to merge 2 commits into
trunkfrom
fix-external-link-new-tab-wrapping

Conversation

@mirka

@mirka mirka commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Closes #84761

What?

Keep the ExternalLink new-tab indicator with the preceding text when the link wraps.

Addresses the ExternalLink portion of #84761, separately from the Link fix in #84806.

Why?

The indicator can wrap onto a line by itself because it is an inline-block. Adding a non-breaking character before that box still permits orphaning in Chromium.

How?

Remove the indicator's inline-block declaration and generate a U+2060 WORD JOINER before its existing arrow text. The existing text wrapper already scopes the default underline to the link text. The markup, class names, arrow text, accessible notice, and click handling remain unchanged.

This changes how consumer style overrides affect the indicator. When the icon is inline, width, height, and vertical margins no longer size or position its box. Underlines applied to the entire anchor can also extend beneath the arrow. An override that explicitly restores inline-block retains its previous layout and wrapping behavior. These compatibility effects are included here for separate assessment.

Testing Instructions

  1. Start Storybook and open Components → @wordpress-components → Navigation → ExternalLink → Wrapping.
  2. Confirm the arrow stays with the final word as the link wraps, with no underline beneath the arrow under the default styles.
  3. Switch the direction toolbar to RTL and repeat. Also try 訪問者が検索する用語とフレーズ in the children control and confirm the arrow stays with the final character.
  4. Repeat with WordPress Global CSS and forced colors enabled.
  5. For the underline override case shown below, apply .components-external-link:hover { text-decoration: underline; } in DevTools and hover the link. The arrow now receives the anchor's underline as well.
  6. To assess existing icon sizing overrides, apply width, height, or vertical margins to .components-external-link__icon. Compare with an explicit display: inline-block override, which restores those box dimensions and the original wrapping behavior.

Screenshots or screencast

Case Before After
Default wrapping ExternalLink with an orphaned new-tab arrow ExternalLink with the arrow kept beside the final word
Anchor underline override on hover Anchor underline override leaves the inline-block arrow undecorated Anchor underline override also underlines the inline arrow

@mirka mirka added the [Type] Bug An existing feature does not function as intended label Oct 15, 2026
@mirka mirka self-assigned this Oct 15, 2026
@github-actions github-actions Bot added [Package] Components /packages/components labels Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

📦 Bundle size

Size Change: -377 B (0%)

Total Size: 8.65 MB

📦 View Changed
Filename Size Change
build/modules/workflow/index.min.js 88.3 kB -36 B (-0.04%)
build/scripts/block-editor/index.min.js 597 kB -33 B (-0.01%)
build/scripts/block-library/index.min.js 442 kB -28 B (-0.01%)
build/scripts/editor/index.min.js 651 kB -73 B (-0.01%)
build/scripts/format-library/index.min.js 89.1 kB -24 B (-0.03%)
build/scripts/widgets/index.min.js 70.2 kB -24 B (-0.03%)
build/styles/block-library/search/style-rtl.css 1.1 kB -27 B (-2.39%)
build/styles/block-library/search/style-rtl.min.css 668 B -27 B (-3.88%)
build/styles/block-library/search/style.css 1.1 kB -26 B (-2.3%)
build/styles/block-library/search/style.min.css 668 B -27 B (-3.88%)
build/styles/block-library/style-rtl.css 22.8 kB -30 B (-0.13%)
build/styles/block-library/style-rtl.min.css 19.3 kB -25 B (-0.13%)
build/styles/block-library/style.css 22.9 kB -25 B (-0.11%)
build/styles/block-library/style.min.css 19.3 kB -26 B (-0.13%)
build/styles/components/style-rtl.css 17 kB +15 B (+0.09%)
build/styles/components/style-rtl.min.css 14.4 kB +13 B (+0.09%)
build/styles/components/style.css 17 kB +13 B (+0.08%)
build/styles/components/style.min.css 14.4 kB +13 B (+0.09%)

019c67a Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 50a6395 trunk % Change
timeToFirstByte 54.25 ms +13.55% -4.33% 53.8 ms +11.43% -2.6% 0.84%
largestContentfulPaint 94 ms +6.38% -6.38% 90 ms +6.67% -4.44% 4.44%
lcpMinusTtfb 35.55 ms +21.52% -7.88% 33.6 ms +7.44% -2.83% 5.8%
wpBeforeTemplate 28.22 ms +21.01% -1.88% 28.6 ms +13.11% -1.5% -1.33%
wpTemplate 20.77 ms +4.53% -2.89% 20.91 ms +4.4% -3.3% -0.67%
wpTotal 50.43 ms +13.42% -4.6% 49.66 ms +12.57% -1.61% 1.55%
wpMemoryUsage 7.61 MB +0% -0% 7.57 MB +0% -0% 0.46%
wpDbQueries 17 +0% -0% 17 +0% -0% 0%

front-end-classic-theme

Metric 50a6395 trunk % Change
timeToFirstByte 45.75 ms +6.12% -2.4% 46.65 ms +11.04% -2.25% -1.93%
largestContentfulPaint 100 ms +4% -0% 102 ms +5.88% -1.96% -1.96%
lcpMinusTtfb 55.25 ms +1.09% -1.99% 54.4 ms +3.31% -1.84% 1.56%
wpBeforeTemplate 26.62 ms +8.04% -2.82% 26.99 ms +8.93% -2.07% -1.37%
wpTemplate 15.76 ms +3.43% -1.65% 16.4 ms +7.93% -2.5% -3.9%
wpTotal 42.86 ms +6.18% -2.96% 43.53 ms +10.77% -1.91% -1.54%
wpMemoryUsage 6.27 MB +0% -0% 6.22 MB +0% -0% 0.71%
wpDbQueries 14 +0% -0% 14 +0% -0% 0%

media-processing

Metric 50a6395 trunk % Change
mediaProcessingJpeg 398.74 ms +0.72% -0.67% 402.71 ms +2.67% -0.44% -0.99%
mediaProcessingAvif 6033.26 ms +0.22% -0.16% 6103.67 ms +0.44% -0.07% -1.15%
mediaProcessingJpegToAvif 4166.94 ms +0.34% -0.31% 4217.91 ms +0.34% -0.3% -1.21%

media-upload

Metric 50a6395 trunk % Change
jpegUploadProcessing 1431.36 ms +37.11% -2% 1433 ms +0.96% -1.03% -0.11%
pngUploadProcessing 214.3 ms +2.54% -13.38% 228.06 ms +3.35% -20.54% -6.03%
largeJpegUploadProcessing 1407.48 ms +0.48% -0.21% 1424.16 ms +0.59% -0.73% -1.17%
multipleImageUploadProcessing 1562.04 ms +8.84% -0.62% 2022.38 ms +2.96% -20.8% -22.76%

post-editor

Metric 50a6395 trunk % Change
serverResponse 415.82 ms +4.23% -8.23% 402.73 ms +6.39% -4.51% 3.25%
firstPaint 482.19 ms +3.79% -29.79% 328.29 ms +40.91% -13.99% 46.88%
domContentLoaded 1096.87 ms +2.33% -1.13% 1079.21 ms +1.71% -4.44% 1.64%
loaded 1098.27 ms +2.33% -1.13% 1080.31 ms +1.73% -4.42% 1.66%
firstContentfulPaint 488.79 ms +2.7% -1.47% 471.64 ms +7.95% -6.15% 3.64%
firstBlock 3219.56 ms +0.47% -1.14% 3119.6 ms +1.87% -2.96% 3.2%
type 18.91 ms +1.37% -4.81% 18.45 ms +2.49% -3.36% 2.49%
typeWithoutInspector 18.19 ms +2.47% -4.62% 17.85 ms +2.52% -0.67% 1.9%
typeWithTopToolbar 22.93 ms +7.68% -2.22% 22.69 ms +6.3% -2.78% 1.06%
typeContainer 8.86 ms +5.19% -8.47% 8.99 ms +7.23% -8.23% -1.45%
focus 115.44 ms +6.52% -4.62% 117.17 ms +2.38% -6.94% -1.48%
firstFocus 219.26 ms +0% -0% 205.42 ms +0% -0% 6.74%
selectAll 473.06 ms +8.71% -7.65% 456.95 ms +6.19% -1.32% 3.53%
listViewOpen 71.85 ms +5.83% -5.11% 68.38 ms +3.03% -2.08% 5.07%
inserterOpen 39.17 ms +7.66% -5.03% 37.25 ms +15.17% -5.37% 5.15%
inserterHover 12.59 ms +6.99% -5.08% 12.62 ms +8.08% -3.01% -0.24%
inserterSearch 9.27 ms +9.28% -3.99% 8.64 ms +8.45% -4.98% 7.29%
loadPatterns 662.02 ms +4.95% -3.33% 663.26 ms +8.62% -1.86% -0.19%
wpTotal 405.58 ms +3.97% -8.43% 392.25 ms +6.1% -4.56% 3.4%
wpMemoryUsage 13.29 MB +0% -0% 13.26 MB +0% -0% 0.28%
wpDbQueries 53.5 +0.93% -0.93% 54 +0% -0% -0.93%

site-editor

Metric 50a6395 trunk % Change
serverResponse 430.41 ms +6.34% -3.46% 418.63 ms +4.06% -6.98% 2.81%
firstPaint 292.24 ms +32.02% -21.02% 252.36 ms +2.98% -7.63% 15.8%
domContentLoaded 1320.32 ms +7.58% -1.23% 1222.61 ms +2.76% -2.59% 7.99%
loaded 1321.83 ms +7.58% -1.24% 1223.86 ms +2.78% -2.57% 8.01%
firstContentfulPaint 559.01 ms +13.46% -7.62% 534.66 ms +1.41% -4.31% 4.55%
firstBlock 4840.38 ms +1.82% -2.24% 4369 ms +0.41% -0.55% 10.79%
type 21.44 ms +4.9% -7.65% 20.3 ms +5.47% -0.39% 5.62%
navigate 147.93 ms +6.42% -10.09% 123.86 ms +15.64% -0.69% 19.43%
loadPatterns 1444.46 ms +8.05% -3.24% 1581.28 ms +5.39% -12.99% -8.65%
loadPages 999.82 ms +0.55% -0.52% 1060.61 ms +27.91% -3.81% -5.73%
wpTotal 419.31 ms +6.32% -3.46% 408.56 ms +4.05% -7.22% 2.63%
wpMemoryUsage 12.35 MB +0% -0% 12.32 MB +0% -0% 0.3%
wpDbQueries 43 +2.33% -0% 43 +2.33% -0% 0%

019c67a Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

default to a list of pages if there are no menus in /test/e2e/specs/editor/blocks/navigation.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeVisible() failed

Locator: locator('[name="editor-canvas"]').contentFrame().getByRole('document', { name: 'Block: Page List' })
Expected: visible
Timeout: 10000ms
Error: element(s) not found

Call log:
  - Expect "toBeVisible" locator('[name="editor-canvas"]').contentFrame().getByRole('document', { name: 'Block: Page List' }) with timeout 10000ms
  - waiting for locator('[name="editor-canvas"]').contentFrame().getByRole('document', { name: 'Block: Page List' })

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation.spec.js:34:34
refuses the drop and uploads nothing in /test/e2e/specs/editor/various/single-file-placeholder-drop.spec.js, passed after 1 failed attempt.
Error: expect(received).toHaveLength(expected)

Expected length: 0
Received length: 1
Received array:  [{"_links": {"about": [{"href": "http://localhost:8889/wp-json/wp/v2/types/attachment"}], "author": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/users/1"}], "collection": [{"href": "http://localhost:8889/wp-json/wp/v2/media"}], "curies": [{"href": "https://api.w.org/{rel}", "name": "wp", "templated": true}], "replies": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/comments?post=244"}], "self": [{"href": "http://localhost:8889/wp-json/wp/v2/media/244", "targetHints": {"allow": ["GET", "POST", "PUT", "PATCH", "DELETE"]}}], "wp:attached-to": [{"embeddable": true, "href": "http://localhost:8889/wp-json/wp/v2/posts/243", "id": 243, "post_type": "post"}]}, "alt_text": "", "author": 1, "caption": {"rendered": ""}, "class_list": ["post-244", "attachment", "type-attachment", "status-inherit", "hentry", "entry"], "comment_status": "open", "date": "2026-10-15T16:23:42", "date_gmt": "2026-10-15T16:23:42", "description": {"rendered": "<p class=\"attachment\"><a href='http://localhost:8889/wp-content/uploads/2026/10/d1b2e1b6-5349-4fb3-b7a3-06a3a739270b.png'><img loading=\"lazy\" decoding=\"async\" width=\"10\" height=\"10\" src=\"http://localhost:8889/wp-content/uploads/2026/10/d1b2e1b6-5349-4fb3-b7a3-06a3a739270b.png\" class=\"attachment-medium size-medium\" alt=\"\" style=\"width:100%;height:100%;max-width:10px;\" /></a></p>
"}, "featured_media": 0, "filename": "d1b2e1b6-5349-4fb3-b7a3-06a3a739270b.png", "filesize": 80, "guid": {"rendered": "http://localhost:8889/wp-content/uploads/2026/10/d1b2e1b6-5349-4fb3-b7a3-06a3a739270b.png"}, "id": 244, "link": "http://localhost:8889/?attachment_id=244", "media_details": {"file": "2026/10/d1b2e1b6-5349-4fb3-b7a3-06a3a739270b.png", "filesize": 80, "height": 10, "image_meta": {"alt": "", "aperture": "0", "camera": "", "caption": "", "copyright": "", "created_timestamp": "0", "credit": "", "focal_length": "0", "iso": "0", "keywords": [], "orientation": "0", "shutter_speed": "0", "title": ""}, "sizes": {}, "width": 10}, "media_type": "image", "meta": [], "mime_type": "image/png", "modified": "2026-10-15T16:23:42", "modified_gmt": "2026-10-15T16:23:42", "ping_status": "closed", "post": 243, "slug": "d1b2e1b6-5349-4fb3-b7a3-06a3a739270b", "source_url": "http://localhost:8889/wp-content/uploads/2026/10/d1b2e1b6-5349-4fb3-b7a3-06a3a739270b.png", "status": "inherit", "template": "", "title": {"rendered": "d1b2e1b6-5349-4fb3-b7a3-06a3a739270b"}, "type": "attachment"}]
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/single-file-placeholder-drop.spec.js:71:45

019c67a Run

@ciampo

ciampo commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

The code changes look good to me, they fix the wrapping while preserving the default underline behavior.

The main aspect is compat: consumers with overrides can lose icon sizing or vertical positioning, and anchor-level underlines can now extend beneath the arrow.

The woo example looks minor, but we can't assume every consumer's overrides will be affected as lightly. Would a breaking CHANGELOG entry be enough?

@mirka

mirka commented Oct 19, 2026

Copy link
Copy Markdown
Member Author

The main aspect is compat

To be honest I'm leaning towards a won't-fix here, for a couple reasons:

  • This bug has already shipped in a major WP version.
  • The replacement component is already available.
  • The arrow being orphaned is probably better, compared to a styling breakage.

If that sounds acceptable for now, I can close this and the original issue. Of course, always open to revisiting later.

@ciampo

ciampo commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Agreed, we should encourage consumers to refactor to Link from @wordpress/ui

@ciampo ciampo closed this Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Components /packages/components [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Link: New-tab icon can wrap onto its own line

2 participants