Fix copying translations naming its plural catchall after the source into the editor - #4407
Merged
Merged
Conversation
Copying a translation into the editor matches its fields against the ones on screen by id, and the id carries the catchall's name. A translation naming its plural catchall after the source, e.g. `*[other]` where this locale's categories are one/few/many, therefore matched nothing, and the locale's own catchall field stayed empty until a second click. Reduce the catchall to `*` in the id instead of using its name. It is the same field either way.
Copying a translation into the editor wrote its values straight into the field editors from inside the `setState` updater. Each write dispatches an editor change, whose own state update then arrives during React's render phase, which defers the update being made to the next render. The values appeared at once, being written imperatively, but everything React draws from the new fields — the plural labels above all — was a click behind. That is the "takes two clicks" the removed HACK comment described, and what remained visible after the field ids stopped carrying the catchall's name. Record the values instead, and write them in an effect once the update is committed.
# Conflicts: # translate/src/context/Editor.test.jsx # translate/src/context/Editor.tsx
eemeli
requested changes
Aug 17, 2026
eemeli
left a comment
Member
There was a problem hiding this comment.
Code looks good; did not test if it performs as intended, trusting you on that.
eemeli
approved these changes
Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #4398.
Copying a translation into the editor matches its fields against the ones on screen by id, and the id carries the catchall's name. A translation naming its plural catchall after the source, e.g.
*[other]where this locale's categories are one/few/many, therefore matched nothing, and the locale's own catchall field stayed empty until a second click.Reduce the catchall to
*in the id instead of using its name. It is the same field either way.The alternatives would be:
Check out the example string on DEV:
https://pontoon.allizom.org/uk/firefox/all-resources/?string=317622
Same string on PROD:
https://pontoon.mozilla.org/uk/firefox/all-resources/?string=317622
The 1st commit fixes the problem with the input field staying empty after 1st click, and 2nd commit fixes the problem with the right catchall name being used as the label.