https://avo.cool logo
Hey hi hello @Adrian , we've found an odd rende...
# fields
b
Hey hi hello @lemon-wall-20836 , we've found an odd rendering issue. It's about
index_field_wrapper
where custom ERB content gets ignored when the underlying field value is blank. The
render_dash?
method checks
@field.value.blank?
rather than whether custom content was provided, so users' ERB blocks execute (?) but their output is discarded in favor of showing "—". It creates a confusing UX where providing custom content doesn't work unless you remember to add
dash_if_blank: false
. The option name
dash_if_blank
is also misleading - it sounds like it only controls dash display, but it actually determines whether custom content renders at all. It took me quite a while to figure out why my custom field wasn't rendering, and even then only discovered the fix by analyzing your implementation. The issue also masks errors since the ERB runs but never renders, so you don't get feedback when your custom code has problems. Would you consider checking if custom content exists before falling back to blank detection? Something like:
Copy code
def render_dash?
    return false if content.present?

    if @field.type == "boolean"
      @field.value.nil?
    else
      @field.value.blank? && @dash_if_blank
    end
  end
Something like that would respect user intent when they provide custom rendering while preserving the current behavior for standard field display.
m
Thread automatically created by Kevin Nowald (Momentum) in #fields
b
In a run atm, i can create an issue from this if you'd like, just wanted to leave a note before i forget it. 😄
l
Hey Kevin. Thanks for the thorough explanation. Heard you loud and clear. dash_if_blank is undocumented. We’ll get on that to explain that a bit better.
We think that defaulting dash_if_blank to true is a good idea. But I definitely see how that can be a total mistery to someone new. 🙌
b
It's a matter of the name of the variable and the definition of "blank" 😅
My ERB block is not very empty 👀
l
Oh. Ok. So the final value is not blank but Avo picked it up as blank?
S-o it looks like a bug
Please open a GH issue with a reproducible repo. We’d love to fix it