fix(i18n): localize the required-field message when enabling two-factor auth#29780
Open
Sloppy0726 wants to merge 1 commit into
Open
fix(i18n): localize the required-field message when enabling two-factor auth#29780Sloppy0726 wants to merge 1 commit into
Sloppy0726 wants to merge 1 commit into
Conversation
…or auth Submitting the enable-2FA dialog with an empty password showed the browser's own "Please fill out this field." in the browser's locale, not the one set in Cal. Set the message in onInvalid and clear it in the existing onInput so a corrected field can go valid again. field_required already exists and is already translated, so there are no new strings. Add a regression test, and the @components alias vitest needs to mount any apps/web component that uses it.
Contributor
|
Welcome to Cal.diy, @Sloppy0726! Thanks for opening this pull request. A few things to keep in mind:
A maintainer will review your PR soon. Thanks for contributing! |
Contributor
|
Caution Review failedAn error occurred during the review process. Please try again later. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
What does this PR do?
Found this with Cal set to 繁體中文 on an English browser.
The enable-2FA dialog is translated the whole way through,
t("incorrect_password"),t("something_went_wrong")and the rest. Then you press Enter on an empty password field and thebrowser answers in its own language: "Please fill out this field.", where the dialog around it says
此欄位為必填.
Enter is the path that matters here. That
<form onSubmit={handleSetup}>holds the password inputand nothing else — Continue lives down in the footer, inside the other
<Form>, and isdisableduntil you type. A form with one field and no submit button of its own submits implicitly on Enter,
and
InputFieldpassesrequireddown to the native input, so the message is the browser's torender and it comes out in the browser's locale.
Fix sets the message in
onInvalidand clears it in the existingonInputso a corrected field cango valid again.
field_requiredalready exists and is already translated (zh-TW此欄位為必填, jaこのフィールドは必須です, frCe champ est obligatoire), so there are no new strings and nothingfor lingo.dev.
Nothing else changes — still native validation, still blocks submit on the same field,
handleSetupuntouched. Only the text differs.
Visual Demo
Nothing to screenshot. The bubble is browser chrome, drawn outside the page. So I read it off the
running app instead, on
/settings/security/two-factor-auth, Cal on 繁體中文, browser onen-US,driving the same submission path Enter takes:
validationMessagePlease fill out this field.此欄位為必填Submit stays blocked either way.
How should this be tested?
Nothing special to set up. Settings → Security → Two-factor auth, Cal on any non-English language,
click Enable, then press Enter with the password field empty. Clicking Continue won't show it — the
button is disabled until the field has a value.
Or
yarn vitest run apps/web/components/settings/EnableTwoFactorModal.test.tsx.Mandatory Tasks (DO NOT REMOVE)
The test needed one thing to run at all.
vitest.config.mtsresolves@liband@calcom/webbutnot
@components, so nothing inapps/webthat imports@components/...can be mounted in a test,and this modal pulls in
@components/auth/TwoFactor. Added the alias next to the others, same asapps/web/tsconfig.jsonalready has it. Happy to split that into its own PR if you'd rather keepthis one to the fix.
Typecheck passes. Typing into the field clears the message and it goes valid again, so nothing gets
stuck.