Skip to content

Make Translate from origin a button in the field's header that asks first only before it replaces text (T11.7) - #3

Merged
afonic merged 1 commit into
mainfrom
field-action-button
Oct 20, 2026
Merged

afonic merged 1 commit into
mainfrom
field-action-button

Conversation

@afonic

@afonic afonic commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Why

Translate from origin sat in the field's dots menu and always asked first, so translating one field took three clicks, even when the field had nothing to lose.

What changes

  • The action is a quick action: an icon button in the field's header, with the book icon used elsewhere in Tolk. Its title is the tooltip and the aria-label. Core lists an addon's actions before the fieldtype's own, so it comes first in the header's group (before Bard's Expand, Collapse and Fullscreen).
  • It asks first only when the translation could lose text: the field holds text, and that text isn't the origin's. A field that is empty (an empty Bard paragraph included), or that still shows the origin's text, is translated at once. In Statamic, an untranslated field shows the origin's text in the localization's form, so this covers most fields that aren't translated yet. The confirmation's wording is unchanged. Undo in the banner still puts the field back.
  • While a translation runs, the buttons stay in place, disabled. Before, the action was hidden, because dropdown items ignore disabled and quick buttons don't.
  • Focus: Cancel and Esc give the focus back to the button. A browser drops the focus of a button once it is disabled, so after a translation starts, with or without the confirmation, a lost focus moves into the banner, as after the confirmation before.
  • The prompt, context and options sent are unchanged: the same plan as before, limited to the field.
  • Docs: docs/editor.md ("Translating one field"), the README's feature line, docs/marketplace-listing.md and CHANGELOG.md (Unreleased).

Tracked as T11.7 in TASKS.md.

Checks

  • npm test: 772 passed. fieldActions.test.js has 5 new and 4 changed tests, and 9 mutations of the new code each fail one.
  • vendor/bin/pest --parallel: 4,008 passed
  • vendor/bin/pint --test: clean
  • npm run cp:build: committed, and a fresh build matches
  • tests/Browser/field-action.spec.js: 3 passed. The button is in the same headers as before and in no others, a typed title asks first, both buttons are disabled while the translation runs, and the untranslated Bard field translates without a dialog, with the focus in the banner afterwards.
  • Full browser suite: 69 passed, 4 skipped, 2 failed, both in editor-push.spec.js on the origin page, where the button never appears:
    • "Update translations changes only the edited paragraph" fails on main too whenever the spec runs after editor-options.spec.js (a Bard image stored wrapped in a paragraph), and passes on its own.
    • "Translate into…" (the button not disabled after typing) failed only in the full run and passed in four reruns.

…irst only before it replaces text of the localization's own
@afonic
afonic merged commit 33094d9 into main Oct 20, 2026
2 of 14 checks passed
@afonic
afonic deleted the field-action-button branch October 20, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant