Closed (fixed)
Project:
Drupal core
Version:
8.7.x-dev
Component:
views.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
1 Oct 2015 at 12:05 UTC
Updated:
4 Dec 2018 at 12:59 UTC
Jump to comment: Most recent, Most recent file

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 commentedComment #8
marthinal 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 commentedComment #10
marthinal commentedAssigned to @joyceg 1 year ago... I'm going to work on it. Needs tests.
Comment #11
marthinal commentedComment #13
marthinal commentedComment #14
marthinal commentedLet's try again.
Comment #16
marthinal 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 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 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 commentedComment #26
joe_carvajalComment #27
luismagr 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 commentedComment #29
dawehnerIt'd be kinda nice to have some documentation about what is going on here :)
Comment #30
dawehnerComment #31
shreya shetty commentedHi @dawehner i have made the improvement as per your suggestion . Please find the patch for the same
Comment #32
amit.drupal 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 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 commentedAdded the same logic to Stable
views-view.html.twigand fixed the indents.Only question is whether there needs to be a specific test for Stable.
Comment #39
john cook 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 commentedFrom alexpott's comment in #40 I've:
Drupal\Tests\views\Functional\ViewTestBaseComment #43
dinesh18 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 commentedChanging the status to RTBC
Comment #45
cilefen 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 commentedPatch #42 worked for me also.
Comment #49
ada hernandez 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 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?