Problem/Motivation

Currently custom tables with sticky headers don't work out of the box.

Steps to reproduce

Create a custom form with sticky header
'#sticky' => TRUE,

Proposed resolution

As for for the template gin/templates/views/views-view-table.html.twig
which has a wrapper div with the class gin-table-scroll-wrapper

The table template templates/dataset/table.html.twig
should have a wrapper div with the class gin-table-scroll-wrapper instead of the current layer-wrapper gin-layer-wrapper

Issue fork gin-3344925

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

abelass created an issue. See original summary.

abelass’s picture

StatusFileSize
new433 bytes

Here is a patch

paul121 made their first commit to this issue’s fork.

paul121’s picture

I am experiencing this as well. Here is my temporary fix - add gin-table-scroll-wrapper class in a wrapper container:

    // Add table wrapper for gin-table-scroll-wrapper class.
    $form['table-wrapper'] = [
      '#type' => 'container',
      '#attributes' => [
        'class' => ['gin-table-scroll-wrapper'],
      ],
      'table' => $form_table,
    ];
    return $form;

I imagine that the patch in #2 works. But it seems likely that the layer-wrapper and gin-layer-wrapper classes are used for other things, so maybe don't remove them? I think you could add gin-table-scroll-wrapper and be just fine.

paul121’s picture

Status: Active » Needs review
abelass’s picture

@paul121, you are right of course.

As the views template didn't have other classes, I just removed them.

saschaeggi made their first commit to this issue’s fork.

saschaeggi’s picture

Status: Needs review » Closed (duplicate)
saschaeggi’s picture

saschaeggi’s picture

Status: Closed (duplicate) » Active
saschaeggi’s picture

Status: Active » Needs review

@paul121 I reopened this issue as #3293369: Table header overflow issue for multiple user role on permissions page. seems to take longer than expected. Please review, thanks!

saschaeggi’s picture

saschaeggi’s picture

paul121’s picture

Status: Needs review » Reviewed & tested by the community

Great, my table with '#sticky' => TRUE now works without my workaround described in #4.

saschaeggi’s picture

Status: Reviewed & tested by the community » Fixed

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

uri_frazier’s picture

StatusFileSize
new79.04 KB

I still get the bug described in issue https://www.drupal.org/project/gin/issues/3338209 (Sticky header triggered to early) even after updating to 3.0.0-rc4. This is while using Chrome 114.0.5735.198 and Firefox 114.0.1

(See screenshot gin_sticky_header_bug_screenshot.jpg ).

sahal_va’s picture

StatusFileSize
new285.99 KB

I am also getting the same issue mentioned in https://www.drupal.org/project/gin/issues/3338209
Issue occurs only when the table view has more number of columns. (ie. when the horizontal scroller appears)
See screenshot.
/files/issues/2023-07-06/Screenshot%202023-07-06%20at%2011.38.37%20AM.png

Note: Horizontal scroller div has ' --is-sticky' class

abelass’s picture

I confirm, bug is not resolved in 8.x-3.0-rc4

rveillard’s picture

Hi, I confirm #19, the issue is still occurring when the horizontal scrollbar appears.
Can you please reopen this issue so it can be fixed ?
Thanks

Tested on rc6

kostask made their first commit to this issue’s fork.

asherry’s picture

Issue summary: View changes

I'm still seeing this issue as well with the paragraphs report. That module is just calling:

    // Table output.
    $table['table'] = [
      '#type' => 'table',
      '#title' => $this->t('Paragraphs Report'),
      '#header' => $tabular['header'],
      '#sticky' => TRUE,
      '#rows' => $chunks[$current_page] ?? [],
      '#empty' => $this->t('No components found. <br /> You may need an Admin user to enable content types on the "Settings" tab and click the "Update Report Data" button.'),
    ];

But the <thead> element ends up with this even before you scroll down.

position: sticky;
z-index: 500;
top: var(--drupal-displace-offset-top)
asherry’s picture

Issue summary: View changes

accidentally updated summary, fixed summary for issue

asherry’s picture

Issue summary: View changes