The table headers are repeating themselves instead of adding rows to the table.
Steps to reproduce:
- Drupal 8.3.5 clean install.
- Create a view of basic pages with a table format.
- Use the Infinite Scroll pager and Click to load (any number of) items
When you click load more, the table headers repeat each time instead of adding more rows to the table. I've toggled the Views ajax on/off and played with some of the Table format settings, but this still happens.
Attached a screenshot of loading one item at a time.
Comment | File | Size | Author |
---|---|---|---|
#65 | 2899705_65.patch | 7.43 KB | init90 |
#53 | 2899705-53.patch | 6.4 KB | acbramley |
Comments
Comment #2
sugaroverflow CreditAttribution: sugaroverflow commentedComment #3
Jed_BH CreditAttribution: Jed_BH commentedI had a look at the code, and in it there are no rules to prevent that from happening. Unfortunatley, I am not experienced enough to poke at it yet.
An easier workaround, for the time being, is to hide all headers except the first one like this in CSS, or less:
Comment #4
Madis CreditAttribution: Madis at ADM Interactive commentedThis might do the trick.
Comment #5
smazThe patch in #4 works for me, thanks!
However, would it be better to do this with an attribute? i.e. in views_infinite_scroll_preprocess_views_view(), check if the display is set to table mode & add an attribute similar to data-drupal-views-infinite-scroll-content-wrapper. Then in javascript we can check for this attribute & if present, rather than check for $(contentWrapperSelector + ' tbody').length - if there is a table within the rendered results (but not using table mode) this could trigger that check? The attribute method wouldn't.
Leaving as needs review rather than RTBC so we can discuss the above.
Comment #6
acbramley CreditAttribution: acbramley at PreviousNext for Transport for NSW commentedHere's a failing test. Going to look into changing the wrapper at a plugin level.
Comment #8
acbramley CreditAttribution: acbramley at PreviousNext for Transport for NSW commentedI tried looking at a solution from the preprocess level but I'm not sure if it'll be possible. The problem is is that in views_infinite_scroll_preprocess_views_view(),
$vars['rows']
only contains the row results. It's not until template_preprocess_views_view_table in views.theme.inc that it adds the rows and headers into different keys in $variables. Since the 2 hooks have no way of interacting I'm not sure if this is possible without a decent change in architecture.Having issues with the tests running locally so I'm uploading a patch with #6 and #4 combined to see if that passes.
Comment #9
Madis CreditAttribution: Madis as a volunteer commentedI agree that the patch in #4 is using a too generic selector which may cause messy results if there are any unrelated tables inside the wrapper. Maybe this one will be good enough (thanks for the test, acbramley!).
Comment #11
Madis CreditAttribution: Madis as a volunteer commentedMessed it up a bit :)
Comment #12
Madis CreditAttribution: Madis as a volunteer commentedComment #13
Madis CreditAttribution: Madis as a volunteer commentedMade the selector safer.
Comment #14
vistree CreditAttribution: vistree commentedHi, same problem is for the Drupal 7.x-2.1 Version. Is there a backport for the patch?
Comment #15
vistree CreditAttribution: vistree commentedOK, problem for 7.x-2.1 is solved with the patch in https://www.drupal.org/project/views_infinite_scroll/issues/2736419#comm...
Comment #16
jackbravo CreditAttribution: jackbravo commented#2899705-13: Headers in table format repeat on load more instead of adding rows is working fine :-).
Comment #17
DanieleN CreditAttribution: DanieleN commentedDoesn't work for me with version 8.x-1.5 :(
What do you need for reproduce this?
Comment #18
DanieleN CreditAttribution: DanieleN commentedComment #19
jackbravo CreditAttribution: jackbravo commented@Daniele Nicastro maybe the javascript console is showing some errors? Are you using a custom theme? Maybe you are customizing the twig output of the table?
Comment #20
Honza Pobořil CreditAttribution: Honza Pobořil as a volunteer commentedIs this bug also in 1.5 or it was introduced later?
If you will not reply in a ~week I will release 1.6 from the current dev.
Comment #21
swilmes CreditAttribution: swilmes commentedJust applied the patch in #13 on Drupal 8.6.15 and it applies fine but doesn't seem to do anything. The load more button still loads in the table headers.
Comment #22
Amsteri CreditAttribution: Amsteri as a volunteer and at Drudesk commentedComment #23
Amsteri CreditAttribution: Amsteri as a volunteer and at Drudesk commentedComment #24
Amsteri CreditAttribution: Amsteri as a volunteer and at Drudesk commentedComment #25
Yury N CreditAttribution: Yury N as a volunteer commentedRe-rolling patch in #24 against current 8.x-1.x
Comment #26
Yury N CreditAttribution: Yury N as a volunteer commentedFixed line indents.
Comment #27
AnybodyPlease contribute to #3098132: [MASTER] Handle style plugin specific wrappers around views rows properly to find a clever solution and write tests for all core and contrib views style plugins. :)
The patches here show one possible solution but should then be more generalized. We shouldn't add case if clauses for specific views style plugins or > thead, ... That's why I'd suggest to close this issue in favor of #3098132?
Comment #28
AnybodyComment #29
bethany.g CreditAttribution: bethany.g commentedIt sounds like some things may need to change from an approach standpoint, but FWIW, the latest patch (from #26) reverses a change/fix made in https://www.drupal.org/project/views_infinite_scroll/issues/2945524.
Comment #30
Lukas von BlarerThe patch in #26 works for me.
Comment #31
anuradha.zinjade CreditAttribution: anuradha.zinjade commented#4 Work for me.
Comment #32
Neslee Canil PintoPatch doesn't apply to the latest dev codebase, needs a reroll
Comment #33
Suresh Prabhu Parkala CreditAttribution: Suresh Prabhu Parkala at Specbee commentedRe-rolled patch, please review!
Comment #34
himanshu_sindhwani CreditAttribution: himanshu_sindhwani for Drupal India Association commentedpatch in #33 no longer applies.
Comment #35
Suresh Prabhu Parkala CreditAttribution: Suresh Prabhu Parkala at Specbee commentedRe-rolled patch.
Comment #36
acbramley CreditAttribution: acbramley at PreviousNext commentedThe tests from #6 need to be added back in and should be uploaded as 2 new patches with the failing tests again + the fix and tests.
Comment #37
netgeek123 CreditAttribution: netgeek123 commentedAre these successful patches going to be included into a new version? There seems to be a lot.
Comment #38
jukka792 CreditAttribution: jukka792 as a volunteer commentedApplied #35 to 8.x-1.8 but still the table header is repeated. Tried with normal table and bootstrap table.
Comment #39
alphex CreditAttribution: alphex commented#35 worked for me on Drupal 8.9.19
Comment #40
RoldanSmirnov CreditAttribution: RoldanSmirnov as a volunteer and commentedI had the same problem with Duplicated headers.
#35 worked for me.
However I have another View Style Module that extends the Table View Style.
In this case, the solution in #35 won't work, so the logic must be duplicated for every View Style extending Table View Style.
I guess a more generic solution could be made by using a different hook in #35 patch.
Maybe instead of: views_infinite_scroll_preprocess_views_view_table
replace with a hook like: hook_preprocess_HOOK, and check if it current View Style is extending Table View Style
hope to find some time to work on it.
Comment #41
mjmorley CreditAttribution: mjmorley at Zoocha commentedThe patch from #35 applied well and worked to stop the duplicating of headers. However it didn't work along side using the views_bulk_operations module, as it cleared the attributes and classes set on the container that are required for VBO to work. This may also have the same effect when used in conjunction with other modules.
I have updated the patch so that it adds these attributes and classes, rather than replaces existing ones.
This is using views_infinite_scroll 1.8, and using Drupal Core 9.3.6.
Comment #42
AnybodyThank you very much @mjmorley - to push this forward it still needs tests.
but your patch is against 8.x-1.x-dev I hope? :)
Comment #43
mjmorley CreditAttribution: mjmorley at Zoocha commentedHi @Anybody, both of the tests on 8.x-1.x have ran successfully :)
Comment #44
Anybody@mjmorley, see #36. These tests from #6 / #8 are still missing in your patch, until the required tests are present, this won't be ready for the final review.
Comment #45
mjmorley CreditAttribution: mjmorley at Zoocha commented@Anybody I seem unable to select any D8 version in testing?
Comment #46
ArantxioThe patch from #41 applied succesfully on the new 2.0 branch on 9.4.8. and seems to be working as expected.
Comment #47
lubwn CreditAttribution: lubwn commentedApplying patch from #41 solves the issue for me as well. Using Drupal 9.4.8, but you need to clear the caches after applying to patch.
Can we push this to production? Seems like something already fixed just needed a bit of googling to find the patch.
Comment #48
acbramley CreditAttribution: acbramley at PreviousNext commentedComment #49
acbramley CreditAttribution: acbramley at PreviousNext commentedFixes test module .info.
Comment #50
acbramley CreditAttribution: acbramley at PreviousNext commentedDev is on 2.0.x now
Comment #51
acbramley CreditAttribution: acbramley at PreviousNext commentedPatch had some fuzz, rerolling for 2.0.x
Comment #53
acbramley CreditAttribution: acbramley at PreviousNext commentedComment #54
abhaisasidharan CreditAttribution: abhaisasidharan as a volunteer and at QED42 commentedThis issue exists for unformatted list and html list as well. The patch does not include that.
Comment #55
mansspams CreditAttribution: mansspams at Wunder commentedThese patches fix one problem instead of underlying issue - this module needs to receive only new content via AJAX, not whole view output as in ordinary pagers. Problem is larger one - with table headers, lists, exposed filters and probably more.
Comment #56
sanju_bera CreditAttribution: sanju_bera as a volunteer commentedThe patch of #10 from https://www.drupal.org/project/views_infinite_scroll/issues/3093929 works well to replace the header and footer of the view.
In addition to the patch, I have made changes to remove the "Headers in table format repeat on load more"
So this patch will help solve the issue of the repeated table headers and static View Result Summary in 2.0.x
Also in 'Global: Result summary', "Displaying @start - @end of @total" might be misleading instead "Displaying 1 - @end of @total" can be used.
Comment #57
AnybodyComment #58
AnybodyComment #59
AnybodyCould we please prove the situation before and after with a test?
Comment #60
florianmuellerCHConfirming that #53 did the trick for me on 2.0.1, while #56 didn't solve the problem?
I'm running Drupal 10.1.0 and I had the issue as well with the table headers being repeated, so I can confirm this is still an issue.
Comment #61
florianmuellerCHComment #62
AnybodyThanks @florianmuellerCH what this module really needs are tests for all core view display formats. That way we can be sure, fixing one doesn't break another.
I assume this won't be merged, until the community did that. Furthermore, it might be discussable to allow alterations for different display formats, as tables just have different structures from lists, grid, ... as one can see.
So this still needs review and work for the tests. #56 has no interdiff, so I'll hide it and we proceed with and review #53.
Comment #63
AnybodyNeeds tests, please.
Comment #64
init90I've noticed one problem with the patch above in case when using the option 'Grouping by field' its value is lost for results loaded by scroll.
Comment #65
init90Here is a patch that saves the grouping field(caption) with the next table data load.