Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiI18n] Fixed EuiContext.i18n's mappingFunc not being called for EuiI18n with multiple tokens and function callbacks #5748

Merged
merged 5 commits into from
Mar 28, 2022

Conversation

cee-chen
Copy link
Member

@cee-chen cee-chen commented Mar 28, 2022

Summary

I noticed this while attempting to QA #5743 with Babelfish checked in local dev.

Screencaps

Multiple tokens

Before

After

Function interpolation

Before

After

Checklist

@@ -61,7 +61,10 @@ function lookupToken<
return errorOnMissingValues(token);
}
// @ts-ignore TypeScript complains that `DEFAULT` doesn't have a call signature but we verified `renderable` is a function
return renderable(values);
const rendered = renderable(values);
return (i18nMappingFunc && typeof rendered === 'string'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thompsongl You were totally right in #5743 (comment) about needing to check for a string type, the unit tests helped me confirm that it will error if the returned render is JSX.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_5748/

Copy link
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch, fix, and tests! ❤️

@cee-chen
Copy link
Member Author

Thanks y'all!

@cee-chen cee-chen merged commit c162a15 into elastic:main Mar 28, 2022
@cee-chen cee-chen deleted the i18n-fixes branch March 28, 2022 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants