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.

CommentFileSizeAuthor
#65 2899705_65.patch7.43 KBinit90
#56 2899705-56.patch3.76 KBsanju_bera
#53 interdiff-2899705-51-53.txt730 bytesacbramley
#53 2899705-53.patch6.4 KBacbramley
#51 2899705-51.patch6.37 KBacbramley
#49 interdiff-2899705-48-49.txt605 bytesacbramley
#49 2899705-49.patch6.37 KBacbramley
#48 2899705-48.patch6.46 KBacbramley
#41 2899705-41--table-header-duplication.patch3.05 KBmjmorley
#35 2899705-35.patch2.98 KBSuresh Prabhu Parkala
#34 Screenshot 2021-02-11 at 4.39.57 PM.png67.96 KBhimanshu_sindhwani
#33 2899705-33.patch3.08 KBSuresh Prabhu Parkala
#26 table_tbody_append-2899705-26.patch2.93 KBYury N
#25 table_tbody_append-2899705-25.patch3.03 KBYury N
#24 table_tbody_append-2899705-24.patch2.82 KBAmsteri
#22 fixed-append-rows-2899705-22.patch2.29 KBAmsteri
#13 table_tbody_append-with-test-2899705-13.patch5.92 KBMadis
#13 table_tbody_append-2899705-13.patch2.29 KBMadis
#11 table_tbody_append-with-test-2899705-11.patch5.91 KBMadis
#11 table_tbody_append-2899705-11.patch2.29 KBMadis
#9 table_tbody_append-with-test-2899705-9.patch5.89 KBMadis
#9 table_tbody_append-2899705-9.patch2.26 KBMadis
#8 2899705-8.patch4.2 KBacbramley
#6 2899705-failing-test.patch3.66 KBacbramley
#4 table_tbody_append-2899705-4.patch554 bytesMadis
Screen Shot 2017-08-03 at 11.41.07 AM.png116.63 KBsugaroverflow
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sugaroverflow created an issue. See original summary.

sugaroverflow’s picture

Issue summary: View changes
Jed_BH’s picture

I 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:

.views-infinite-scroll-content-wrapper{
	.table-responsive table thead{
		display: none;
	}
	.table-responsive:first-child table thead{
		display: table-header-group;
	}
}
Madis’s picture

Status: Active » Needs review
FileSize
554 bytes

This might do the trick.

smaz’s picture

The 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.

acbramley’s picture

Version: 8.x-1.3 » 8.x-1.x-dev
FileSize
3.66 KB

Here's a failing test. Going to look into changing the wrapper at a plugin level.

Status: Needs review » Needs work

The last submitted patch, 6: 2899705-failing-test.patch, failed testing. View results

acbramley’s picture

Status: Needs work » Needs review
FileSize
4.2 KB

I 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.

Madis’s picture

I 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!).

Status: Needs review » Needs work

The last submitted patch, 9: table_tbody_append-with-test-2899705-9.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Madis’s picture

Madis’s picture

Status: Needs work » Needs review
Madis’s picture

vistree’s picture

Hi, same problem is for the Drupal 7.x-2.1 Version. Is there a backport for the patch?

vistree’s picture

OK, problem for 7.x-2.1 is solved with the patch in https://www.drupal.org/project/views_infinite_scroll/issues/2736419#comm...

jackbravo’s picture

Status: Needs review » Reviewed & tested by the community
DanieleN’s picture

Doesn't work for me with version 8.x-1.5 :(

What do you need for reproduce this?

DanieleN’s picture

Status: Reviewed & tested by the community » Needs work
jackbravo’s picture

@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?

Honza Pobořil’s picture

Is 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.

swilmes’s picture

Just 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.

Amsteri’s picture

Amsteri’s picture

Status: Needs work » Needs review
Amsteri’s picture

Yury N’s picture

Re-rolling patch in #24 against current 8.x-1.x

Yury N’s picture

FileSize
2.93 KB

Fixed line indents.

Anybody’s picture

Please 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?

Anybody’s picture

bethany.g’s picture

It 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.

Lukas von Blarer’s picture

The patch in #26 works for me.

anuradha.zinjade’s picture

#4 Work for me.

Neslee Canil Pinto’s picture

Status: Needs review » Needs work

Patch doesn't apply to the latest dev codebase, needs a reroll

   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3005  100  3005    0     0   1946      0  0:00:01  0:00:01 --:--:--  1944
error: patch failed: views_infinite_scroll.module:36
error: views_infinite_scroll.module: patch does not apply
Suresh Prabhu Parkala’s picture

Status: Needs work » Needs review
FileSize
3.08 KB

Re-rolled patch, please review!

himanshu_sindhwani’s picture

Status: Needs review » Needs work
FileSize
67.96 KB

patch in #33 no longer applies.
error

Suresh Prabhu Parkala’s picture

Status: Needs work » Needs review
FileSize
2.98 KB

Re-rolled patch.

acbramley’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

The 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.

netgeek123’s picture

Are these successful patches going to be included into a new version? There seems to be a lot.

jukka792’s picture

Applied #35 to 8.x-1.8 but still the table header is repeated. Tried with normal table and bootstrap table.

alphex’s picture

#35 worked for me on Drupal 8.9.19

RoldanSmirnov’s picture

I 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.

mjmorley’s picture

The 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.

Anybody’s picture

Thank you very much @mjmorley - to push this forward it still needs tests.

This is using views_infinite_scroll 1.8

but your patch is against 8.x-1.x-dev I hope? :)

mjmorley’s picture

Hi @Anybody, both of the tests on 8.x-1.x have ran successfully :)

Anybody’s picture

@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.

mjmorley’s picture

@Anybody I seem unable to select any D8 version in testing?

Arantxio’s picture

The patch from #41 applied succesfully on the new 2.0 branch on 9.4.8. and seems to be working as expected.

lubwn’s picture

Applying 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.

acbramley’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
6.46 KB
acbramley’s picture

FileSize
6.37 KB
605 bytes

Fixes test module .info.

acbramley’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

Dev is on 2.0.x now

acbramley’s picture

Patch had some fuzz, rerolling for 2.0.x

Status: Needs review » Needs work

The last submitted patch, 51: 2899705-51.patch, failed testing. View results

acbramley’s picture

Status: Needs work » Needs review
FileSize
6.4 KB
730 bytes
abhaisasidharan’s picture

This issue exists for unformatted list and html list as well. The patch does not include that.

mansspams’s picture

These 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.

sanju_bera’s picture

The 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.

Anybody’s picture

Priority: Normal » Major
Anybody’s picture

Anybody’s picture

Issue tags: +Needs tests

Could we please prove the situation before and after with a test?

florianmuellerCH’s picture

Confirming 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.

florianmuellerCH’s picture

Anybody’s picture

Thanks @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.

Anybody’s picture

Status: Needs review » Needs work

Needs tests, please.

init90’s picture

I'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.

init90’s picture

Here is a patch that saves the grouping field(caption) with the next table data load.