Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem
The empty text "No content available" appears twice in the content view:
Steps to replicate:
- Install the minimal profile.
- Enable Views
- Go to admin/content
Proposed resolution
Make sure it only appears once.
Remaining tasks
Repair. Test. Commit.
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#49 | 2578251-49.patch | 2.37 KB | Ada Hernandez |
Comments
Comment #2
alexpottI think might be a duplicate of #2570895: FieldPluginBase can duplicate a suffix
Comment #3
pfrenssenI checked if this was perhaps a duplicate of #2570895: FieldPluginBase can duplicate a suffix, but the patch in that issue doesn't solve this.
Comment #4
joyceg CreditAttribution: joyceg commentedComment #8
marthinal CreditAttribution: marthinal at Bluespark commentedI had the same problem working on my current project.
From \Drupal\views\Plugin\views\display\DisplayPluginBase::elementPreRender() when a view is empty we add the #empty property but also we add the #empty property when building the form:
If we have a form we don't need to add the value #empty again to the output but let's see the result of the tests.
Comment #9
marthinal CreditAttribution: marthinal at Bluespark commentedComment #10
marthinal CreditAttribution: marthinal at Bluespark commentedAssigned to @joyceg 1 year ago... I'm going to work on it. Needs tests.
Comment #11
marthinal CreditAttribution: marthinal at Bluespark commentedComment #13
marthinal CreditAttribution: marthinal at Bluespark commentedComment #14
marthinal CreditAttribution: marthinal at Bluespark commentedLet's try again.
Comment #16
marthinal CreditAttribution: marthinal at Bluespark commentedComment #17
joe_carvajal#16 works like a charm.
The text appears duplicated before the patch, and it deletes one of them.
I'll work in the test.
Comment #18
joe_carvajalSorry for the status change. I'll do the test.
Comment #19
marthinal CreditAttribution: marthinal at Bluespark commented@joe_carvajal Great thanks!
Anyway I think we could verify that the empty behaviors are empty. Let's try this patch.
Comment #20
marthinal CreditAttribution: marthinal at Bluespark commentedFeel free to work on the test then. We need to parse and verify that the *Empty text* only appears once.
Comment #21
joe_carvajalI tried it, but I don't know how to perform this test. I won't work in this issue from now on.
Comment #22
joe_carvajalI talked with marthinal and I'll try again :)
Comment #23
joe_carvajalTo reproduce the issue you only need to add at least an exposed filter.
Comment #24
joe_carvajalI added a view that reproduces the error, but the test isn't created yet.
Comment #25
marthinal CreditAttribution: marthinal at Bluespark commentedComment #26
joe_carvajalComment #27
luismagr CreditAttribution: luismagr as a volunteer and at Front ID commentedI've worked on this issue and when the patch is not applied, the test also receive the text message once. If you access to the view through the navigator, you can see the message twice but only once in the test.
I attach the patch without the testing view created by @joe_carvajal (also thanks for that view). I have created the test getting directly the path /admin/content.
Thanks to @marthinal for his support. I really appreciate it. You are awsome!
Comment #28
idebr CreditAttribution: idebr at ezCompany commentedComment #29
dawehnerIt'd be kinda nice to have some documentation about what is going on here :)
Comment #30
dawehnerComment #31
Shreya Shetty CreditAttribution: Shreya Shetty as a volunteer and at Trigyn Technologies Ltd commentedHi @dawehner i have made the improvement as per your suggestion . Please find the patch for the same
Comment #32
amit.drupal CreditAttribution: amit.drupal as a volunteer and at gai Technologies Pvt Ltd for gai Technologies Pvt Ltd commentedStep to test patch #31
1 - Install the minimal profile.
2 - Enable Views
3 - Go to admin/content and create content type and add new content.
4 - Go to admin/content page and filter "Published status" and found "No content available." text display in two times.
5 - Apply patch #31 and again display same page and found "No content available." text display in one time.
Issues is resolve and patch working fine
Comment #33
marthinal CreditAttribution: marthinal at Bluespark commentedAs discussed with @dawehner, the test should fail and we cannot reproduce the problem from the default theme (classy). We change the theme from the setup and I added logic to the tpl to only render the empty results when rows are empty.
Comment #35
dawehnerThe only problem I have with that is that this doesn't fix the problem with custom templates. I assume this is fine.
Comment #36
star-szrThe template in Classy already has this logic so it doesn't need to be updated.
This is a case where we should actually update Stable too since it's not changing markup but fixing a bug with the display logic.
Also, the
{{ rows }}
and{{ empty }}
are indented by two spaces too many. Looks to be indented four spaces instead of two.Comment #37
eporama CreditAttribution: eporama at Acquia commentedAdded the same logic to Stable
views-view.html.twig
and fixed the indents.Only question is whether there needs to be a specific test for Stable.
Comment #39
John Cook CreditAttribution: John Cook at Creode commentedI've tested the patch from #37.
This works as shown by marthinal's image in #8.
I removed the fix and ran the test and got this:
With the fix re-instated:
(NB: I've removed passes that aren't applicable.)
This has a fix in Stable as requested by Cottser in #36.
This all looks good and is RTBC.
Comment #40
alexpottThis should be \Drupal\Tests\views\Functional\ViewTestBase
Also I'm concerned about introducing extra spaces with the new templates? Should we be doing something like
?
How come the new line here?
Comment #41
star-szrPer @alexpott's point, to get this to output the same amount of whitespace the following should work:
or
{% if rows -%}
{{ rows }}
{% elseif empty -%}
{{ empty }}
{% endif %}
I think the if's themselves don't need to be "trimmed", just the part before the variable is printed.
Comment #42
John Cook CreditAttribution: John Cook at Creode commentedFrom alexpott's comment in #40 I've:
Drupal\Tests\views\Functional\ViewTestBase
Comment #43
Dinesh18 CreditAttribution: Dinesh18 as a volunteer commentedI have applied the patch mentioned in comment #42 and it works as expected.
PFA before and after patch screengrab.
Looks like RTBC.
Comment #44
Dinesh18 CreditAttribution: Dinesh18 as a volunteer commentedChanging the status to RTBC
Comment #45
cilefen CreditAttribution: cilefen as a volunteer commentedThank you, everyone.
This test seems out of place in the test hierarchy. Should it be somewhere in Drupal\Tests\views\Functional?
In other test classes, if setUp() has a Docblock at all, it's an {@inheritdoc}.
Comment #48
webadpro CreditAttribution: webadpro commentedPatch #42 worked for me also.
Comment #49
Ada Hernandez CreditAttribution: Ada Hernandez at MTech, LLC commented#45 I added the docblock and it changed the test view to /functional namespace
Comment #51
johnsiciliPatch #49 works for me. Thank you!
Comment #52
DamienMcKennaComment #53
Vj CreditAttribution: Vj as a volunteer commentedIssue can be reproduced by setting "Stark" as admin theme in standard profile install.
Patch works #49 and resolves issue.
Comment #54
catchCommitted 4284388 and pushed to 8.7.x. Thanks!
Comment #56
DamienMcKennaIs this something that could be backported to 8.6.x?