Skip to content

File: Edit the file and its link from a Content tab - #85973

Draft
jeryj wants to merge 5 commits into
trunkfrom
add/file-content-tab
Draft

jeryj wants to merge 5 commits into
trunkfrom
add/file-content-tab

Conversation

@jeryj

@jeryj jeryj commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What?

Part of #85961. Closes #86202. Depends on #85970 (its commit is included here).

Selecting a File block opens the inspector on a Content tab, like the Image block, whether or not the inline PDF embed is showing. The tab has one Media panel with, in order:

  • File: the shared MediaControl (upload, Media Library, Replace, Reset), the same control Image, Cover and Media & Text use.
  • File name.
  • Link to, a link picker that offers Media file and Attachment page, and Open in new tab, followed by a View button.
  • Show download button, and Download button text while the button is on.

Show inline embed and Height in pixels stay on the Settings tab, under PDF settings.

Why?

The File block has no Content tab today. It opens on Settings, and the file can only be replaced from the toolbar's Replace menu. #85961 tracks giving blocks with a link or media a Content tab built from shared fields, and File has the same gap as the List View children it lists.

How?

  • file/inspector.jsx renders the content controls in InspectorControls group="content" and keeps the PDF settings in the default group. The old Settings panel is gone; its three controls moved to the Content tab.
  • Link to and Open in new tab use MediaLinkControl and MediaLinkNewTabControl from Block Editor: Add a media Link to field #85970, limited to the media and attachment destinations, so the picker suggests only Media file and Attachment page and has no Remove link button. The View button is the shared ViewLinkButton.
  • The Media control calls the same onSelectFile and onUploadError as the toolbar's Replace menu, so replacing a file behaves the same from either place. The toolbar's Replace and Copy URL are unchanged.
  • File name and Download button text are rich text on the canvas. The sidebar fields show their plain text and write back escaped plain text, so typing < or & stays literal instead of becoming markup. Editing them in the sidebar drops inline formatting such as bold, as the Navigation Link Text field does today; Navigation Link: Keep the text formatting when editing in the sidebar #85223 can be adopted here once it lands.
  • Turning off Open in new tab now clears textLinkTarget to undefined instead of false. Both serialize without a target attribute, which the new e2e test checks.
  • The panel's Reset all removes the file, like Image's Media panel, and resets the link, new tab and download button settings.

Testing Instructions

  1. Open a post and insert a File block. Upload a PDF.
  2. With the block selected, the inspector opens on the Content tab, with the inline embed showing on the canvas.
  3. Check the Media panel lists File, File name, Link to, Open in new tab, View, Show download button and Download button text.
  4. Open the Settings tab. Show inline embed and Height in pixels are there.
  5. Back on Content, open Link to. It suggests only Media file and Attachment page, with no Remove link button. Choose Attachment page. The file name on the canvas links to the attachment page (check with the View button).
  6. Type a new File name and Download button text. The canvas updates as you type.
  7. Turn off Show download button. The button and the Download button text field disappear.
  8. Use the File control to replace the file with a non-PDF file. The block shows the new file, and PDF settings are no longer in the Settings tab.
  9. The toolbar's Replace and Copy URL still work.

Testing Instructions for Keyboard

  1. Select a File block and move focus to the inspector (for example with the "Navigate to the next part of the editor" shortcut).
  2. Tab through the Content tab. Every control in the Media panel is reachable and operable: Enter or Space opens the File menu, Enter opens Link to and the arrow keys move between its suggestions, and Space toggles the checkbox and switch.
  3. Type in File name and Download button text and confirm the canvas updates.

Screenshots or screencast

Before After
Settings tab with PDF settings, Link to, Open in new tab, Show download button Content tab with File, File name, Link to, Open in new tab, View, Show download button, Download button text

Use of AI Tools

Written with Claude Code.

🤖 Generated with Claude Code

https://claude.ai/code/session_01S1u1vgir2YJpmNhb7h3ESd

…field

Adds the shared pieces for editing links in a block's Content tab (#85961):

- LinkPicker takes `showSuggestions`. With it off, the popover asks for a
  URL and does not search for suggestions, for blocks like Social Icon.
- MediaLinkControl and MediaLinkNewTabControl in block-library's utils
  offer the media link destinations (None, Media file, Attachment page,
  Custom URL via LinkPicker) and Open in new tab in the inspector. Blocks
  choose which destinations to offer, so File can offer only Media file
  and Attachment page.
- The toolbar's ImageURLInputUI now shares its destination matching and
  new tab rel handling with the inspector fields, through the private
  getMediaLinkDestination and getNewTabLinkAttributes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1u1vgir2YJpmNhb7h3ESd
@github-actions github-actions Bot added [Package] Block library /packages/block-library [Package] Block editor /packages/block-editor labels Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

📦 Bundle size

Size Change: +1.26 kB (+0.01%)

Total Size: 8.57 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 542 kB +145 B (+0.03%)
build/scripts/block-library/index.min.js 403 kB +1.04 kB (+0.26%)
build/styles/block-library/editor-rtl.css 12.9 kB +19 B (+0.15%)
build/styles/block-library/editor-rtl.min.css 10.6 kB +19 B (+0.18%)
build/styles/block-library/editor.css 13 kB +19 B (+0.15%)
build/styles/block-library/editor.min.css 10.6 kB +19 B (+0.18%)

592af2e 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.

User Mention: should insert two subsequent mentions in /test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js, passed after 2 failed attempts.
Error: apiRequestContext.fetch: socket hang up
Call log:
  - → POST http://localhost:8889/wp-json/wp/v2/users
    - user-agent: Playwright/1.63.0 (x64; ubuntu 24.04) node/24.20 CI/1
    - accept: */*
    - accept-encoding: gzip,deflate,br
    - X-WP-Nonce: 261eb8607c
    - content-type: application/json
    - content-length: 119
    - cookie: wordpress_test_cookie=WP%20Cookie%20check; wordpress_logged_in_23778236db82f19306f247e20a353a99=admin%7C1793568343%7CmTgyMydwQMKsLaAhW4fPClr1JLnBQ7I9NfjajlGDLSW%7C412552172dd002e573999f9ff30ed586127580db3f3436b5bc70c1eae87df5f1; wp-settings-time-1=1793395544

    at RequestUtils.rest (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/rest.ts:111:39)
    at RequestUtils.createUser (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/users.ts:74:30)
    at map (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js:58:18)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/autocomplete-and-mentions.spec.js:57:13

keeps the inline inserter open when the Block Library panel closes in /test/e2e/specs/editor/various/inserting-blocks.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('button', { name: 'Add block' })
    - locator resolved to <button type="button" aria-pressed="false" aria-haspopup="true" aria-expanded="false" aria-label="Add block" class="components-button block-editor-inserter__toggle is-next-40px-default-size has-icon">…</button>
  - attempting click action
    - waiting for element to be visible, enabled and stable
  - element was detached from the DOM, retrying

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/inserting-blocks.spec.js:614:59
should select by dragging into nested block in /test/e2e/specs/editor/various/multi-block-selection.spec.js, passed after 1 failed attempt.
Error: expect(received).toEqual(expected) // deep equality

- Expected  - 1
+ Received  + 0

  Array [
    1,
-   2,
  ]

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/multi-block-selection.spec.js:569:5
should undo without broken temporary state in /test/e2e/specs/editor/blocks/image.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:image -->
- <figure class="wp-block-image"><img alt=""/></figure>
+ <!-- wp:image {"id":22,"sizeSlug":"full","linkDestination":"none"} -->
+ <figure class="wp-block-image size-full"><img src="http://localhost:8889/wp-content/uploads/2026/10/0f79268b-84db-4d31-a8ab-d172aa52ab53.png" alt="" class="wp-image-22"/></figure>
  <!-- /wp:image -->
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/image.spec.js:432:49

592af2e Run

jeryj and others added 4 commits October 30, 2026 16:13
…icker

Drop the Link to dropdown. The field is a single LinkPicker that offers
Media file and Attachment page above its page suggestions, with a Remove
link button beside the preview. LinkPicker gains transformSuggestions,
passed to its LinkControl.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1u1vgir2YJpmNhb7h3ESd
Move the File block's file, file name, link, new tab and download button
controls to an inspector Content tab, with a Media control to replace the
file. The inline PDF embed settings stay on the Settings tab.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1u1vgir2YJpmNhb7h3ESd
The media Link to field is now a link picker that offers the media file and the attachment page as suggestions, not a dropdown. Open the picker and choose a suggestion, check that only those two are offered with no Remove link button, and anchor the Media button's name so it no longer matches the Link to preview, whose name includes the file URL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S1u1vgir2YJpmNhb7h3ESd
@jeryj
jeryj force-pushed the add/file-content-tab branch from 72474d3 to 592af2e Compare October 30, 2026 21:18

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Package] Block library /packages/block-library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File: Add a Content tab

1 participant