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

Better handling for empty values in some attributes #960

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

jagthedrummer
Copy link
Contributor

@jagthedrummer jagthedrummer commented Nov 21, 2024

Fixes #247

The attribute display for date, date_and_time, and boolean_button did some unexpected things if the attribute in question was empty.

  • boolean_button would display a label, but no value.
  • date and date_and_time would display the word "Never" but without a label

All of the other attribute type don't display anything if their value is empty.

In order to allow apps to continue to show those values even if they are empty (but now with a label) those attribute partials now accept a display_when_blank option. It can be used like this:

<%= render 'shared/attributes/date', attribute: :date_field_value, display_when_blank: true %>

Before:

CleanShot 2024-11-21 at 10 26 41

After, default behavior:

CleanShot 2024-11-21 at 10 29 54

After, passing display_when_blank: true:

CleanShot 2024-11-21 at 10 34 09

@jagthedrummer jagthedrummer merged commit 036d606 into main Nov 21, 2024
28 checks passed
@jagthedrummer jagthedrummer deleted the jeremy/empty-attributes branch November 21, 2024 16:51
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.

Date attribute partial does not render the heading if the date is missing
1 participant