- First commit to issue fork.
- 🇮🇳India Meeni_Dhobale
I tried to solve it, and spend some time but, but didn't understand why this happening, this issue not coming in Drupal core 9.5. I compared both files and view for the same blocks in both Drupal versions but didn't see any difference. Not understanding why this happening, If someone has any idea regarding it please share.
- 🇦🇺Australia darvanen Sydney, Australia
@Meeni_Dhobale are you saying that you followed the steps to reproduce using 9.5.x and were not able to reproduce the problem? Can I check that you inspected the HTML output of the page, not just what the browser printed on the screen?
- 🇮🇹Italy finex
Hi, after a bit of testing I realized that, in my case, the problem was related to twig debugging. In fact, in the development environment I have twig debugging active and therefore the empty fields are also visible, while in production, with debugging deactivated, the empty fields are correctly hidden.
- 🇮🇳India anand.toshniwal93
After attempting to replicate the scenario, I discovered that disabling twig debug resolves the issue, resulting in everything functioning as expected. This aligns with the observation mentioned in the previous comment 🐛 For a view displaying an optional field, 'hide if empty' doesn't work where a node matches the view query but the field is empty Active , where the problem was rectified by turning off twig debugging.
Tried with Drupal: 9.5.11
- 🇮🇳India Vivek Panicker Kolkata
After reading the above comment, I have a question that shouldn't the original field value be checked before rendering, instead of waiting for the render phase to check if the field is empty or not?
- 🇬🇧United Kingdom donaldp
I've just hit this issue or similar and can confirm that it only appears with twig debugging enabled.
This was happening in a view using views_accordion showing 3 fields for each row, one of which was empty. Despite having "Hide if empty" and "Hide rewriting if empty" the field heading still appeared when twig debugging was enabled. This was both in the views preview and the view page.Running Drupal 10.3.2 with all modules up to date.
- 🇺🇸United States phillamb168
Just to confirm what finex and anand.toshniwal93 have said - disabling twig debugging fixes this.