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

fix(enum-utils): return nil if option name is blank #447

Merged
merged 1 commit into from
Mar 6, 2023

Conversation

difernandez
Copy link
Contributor

@difernandez difernandez commented Mar 6, 2023

Context

In #442 we added support for automatic enum translation for Rails built-in enums

Changes

This PR fixes an issue that would show the whole enum hash as the translation for an empty value when using tag_column or tag_row. Thanks to @stadia for reporting this issue.
The fix returns nil as the translation for a blank value. Returning nil instead of an empty string keeps the same behavior as before the translation changes, which uses activeadmin's default translation for unset value

Before translation changes
image

After translation changes, before fix
image

After fix
image

I'm not adding this to the changelog, as it fixes something that is still unreleased.
I also added a test case for enum utils for when translate_enum_option is used with not nil value that is not present in enum, to account for all three cases.

@difernandez difernandez merged commit c95be7d into master Mar 6, 2023
@difernandez difernandez deleted the fix-enum-translation-when-blank branch March 6, 2023 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants