Problem/Motivation

Olivero doesn't support Drupal core's responsive tables API (the priority-low/priority-medium classes on th and td).

Steps to reproduce

Note: Olivero isn't typically used as the admin theme. This is just a quick method for viewing a responsive table.

  1. Install Drupal with the standard profile.
  2. Log in as admin.
  3. Set Olivero as the administration theme (at the bottom of /admin/appearance).
  4. Go to /admin/content.
  5. Reduce viewport width to less than ~950px.
  6. Look for a button named "Show all columns" between the filters and the table header. The button should be styled as a link.
  7. In the table, look for columns with the header "Author" or "Updated".

Expected behavior

  • The button named "Show all columns" is visible.
  • The "Author" and "Updated" columns are hidden.
  • Clicking the button should show the hidden columns.

Actual behavior

  • The button named "Show all columns" is hidden.
  • The "Author" and "Updated" columns are visible.

Proposed resolution

Olivero should support Drupal core's responsive tables API (the priority-low/priority-medium classes on th and td).

These are already supported by Claro and by the upcoming Gin in core.

To do accomplish this:

  1. Add the responsive cells CSS rules to Olivero's table.pcss.css.
  2. Add theming to style the button as a link in Olivero's button.pcss.css.
  3. Recompile the CSS files (run yarn install && yarn build:css in the core directory).

Remaining tasks

TBD

User interface changes

TBD

Issue fork drupal-3195427

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

katannshaw created an issue. See original summary.

mherchel’s picture

Are we wanting tables to be stacked or stay in a tabular format in mobile view?

No. The best layout for a table depends on its content. There's no way for the theme to know this. So, we can't make assumptions and shift things around.

The best we could do is provide overflow containers, however this is somewhat weird. We'd have to use JavaScript to insert it before rendering, this has performance implications.

My thought is to leave as is. This is not an issue that can be solved for general use (although it can be solved for very specific use cases).

Thoughts?

imalabya’s picture

@mherchel There is some initial work done on Table view overflow issue on mobile. Marked it as a duplicate to mark this as the main issue.

The best we could do is provide overflow containers, however this is somewhat weird. We'd have to use JavaScript to insert it before rendering, this has performance implications.

IMHO, overflow containers should work just fine following the Figna design and POC at https://www.drupal.org/project/olivero/issues/3093249

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

andrewmacpherson’s picture

Are we wanting tables to be stacked or stay in a tabular format in mobile view?

The latter please! The point of tables is that they let you easily compare information by rows/columns. You lose this when stacking them.

The best layout for a table depends on its content. There's no way for the theme to know this. So, we can't make assumptions and shift things around.

We can make a fair assumption that if the author created a table, they considered the row/column relationships to be important. So it's preferable to keep the table layout.

Some approaches to responsive tables create a stacked presentation while preserving table semantics for assistive tech. However sighted users still lose the ability to easily use the row/column relationship.

My thought is to leave as is.

It's rather poor as is. On a small screen you get a slippy page which is hard to keep aligned when attempting to scroll vertically, especially with a touchscreen. It keeps slipping off to the side, into the whole-viewport horizontal overflow.

I recall seeing an early demo of Olivero which had a table inside a horizontally scrolling container. This would be much preferable.

The best we could do is provide overflow containers, however this is somewhat weird. We'd have to use JavaScript to insert it before rendering, this has performance implications.

Any idea how much of a performance impact?

For tables created with the "Table" render element, we could add a wrapper div server-side. Say with a theme_wrapper render property. That should cover Views and Forum module. It wouldn't help with table from the body text field though.

Related: does the core/drupal.tableresponsive library work with Olivero?

Note: the patch in #3192084: Table view overflow issue on mobile. made a scroll container by setting display: block; directly on a HTML table element. This removes the table semantics from the accessibility tree. This approach should NOT be committed without thorough assistive tech testing. Remember Firefox ESR and IE11 in this.

dipakmdhrm’s picture

It looks like the table overflow style from the Olivero PoC has not been implemented yet. Once it's done, it should solve this issue.

catch’s picture

We have column priorities for tables, so it's the responsibility of the module developer to implement those. This seems like it should be 'by design' to me (and possibly an issue opened against styleguide to use the responsive tables API if it's not already).

bnjmnm’s picture

This is something currently happening in all themes. I'm not sure it's reasonable to expect Olivero to address this BUT.... This is addressed in an (at the moment RTBC) Claro issue which implements a solution very similar to the one in the Olivero PoC, but with additional logic to ensure sticky table header compatibility #3068696: Tables overflow on mobile. The plan with that Claro issue was to follow that up with a proposed change to core allowing a #scrollable property to table render arrays that would work in any theme.

So, to avoid too much duplication of work, it may be easiest to land that Claro issue then work on adapting that functionality to Core so Olivero can use it. Or, at the very least start this by copypasting (and changing where needed) what has already been done in Claro. The sticky header part was really tricky and nobody should have to re-discover how to address it 🙂.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

catch’s picture

catch’s picture

Title: Tables can create horizontal scrolling at narrow viewports in Olivero » Olivero does not support core's responsive tables API
Priority: Normal » Major
Issue summary: View changes

Actually no there's a more basic issue - Olivero doesn't support responsive tables at the moment at all. We should do that as a minimum step here I think.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

kentr’s picture

@catch

Olivero doesn't support responsive tables at the moment at all. We should do that as a minimum step here I think.

That's referring to tables where columns can be toggled visible / hidden, such as at /admin/content and /admin/modules, correct?

If so, part of the problem appears to be that Olivero's table.css is missing the responsive table cells rules.

Adding this to Olivero's table.css makes the toggle button work at /admin/content:

/**
 * Responsive table cells.
 */
th.priority-low,
th.priority-medium,
td.priority-low,
td.priority-medium {
  display: none;
}

@media screen and (min-width: 38em) {
  th.priority-medium,
  td.priority-medium {
    display: table-cell;
  }
}

@media screen and (min-width: 60em) {
  th.priority-low,
  td.priority-low {
    display: table-cell;
  }
}

Also, at /admin/modules, that table.css file isn't on the page at all.

catch’s picture

@kentr yes exactly this. Not sure why the library isn't added on admin/modules, although tbh I would make that a spin-off issue since Olivero-as-admin-theme is very niche anyway. However you can have user-facing tables on sites (a views member listing on groups could be in the front end theme for example).

kentr’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new28.1 KB
new28.48 KB

Here's an MR to add support for Olivero, and before / after screenshots.

Though, long-term it might be better to move some of this to a central library and attach it in lib/Drupal/Core/Render/Element/Table.php where the JS library is attached. Specifically, I'm thinking of the changes to table.pcss.css.

Reasoning:

The JS drupal.tableresponsive library looks for those CSS rules to show the toggle button. For Claro they're in a general theme file for tables. It looks like Gin will also have them when it moves to core.

AFAICT, Umami doesn't support responsive tables either.

It looks like the rules are also loaded for pages that only have regular tables.

I'm thinking moving and conditionally adding them would DRY it out, make them available to all themes, and shave some bytes from the CSS when they're not needed.

kentr’s picture

Issue summary: View changes
mherchel’s picture

Status: Needs review » Needs work

Thanks for working on this!

Functionality looks great. Left some comments in the MR (stylistic changes for consistency)

kentr’s picture

Status: Needs work » Needs review

Made some changes per the MR comments.

mherchel’s picture

Bumping to the top of my list. Will look at this shortly!

mherchel’s picture

Status: Needs review » Reviewed & tested by the community

This looks absolutely perfect! Thanks everyone!

Note: the media queries add the screen keyword: media screen and (--md) {. Olivero doesn't normally do this, but I think its appropriate here because if users want to print the content, they should get all columns.

mherchel’s picture

Adjusted contribution credits.

  • godotislate committed 20a3960d on main
    fix: #3195427 Olivero does not support core's responsive tables API
    
    By...

  • godotislate committed 830165dd on 11.x
    fix: #3195427 Olivero does not support core's responsive tables API
    
    By...
godotislate’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed
StatusFileSize
new80.99 KB
new99.62 KB

Committed and pushed 20a3960 to main and 830165d and pushed to 11.x. Thanks!

Tested myself per reproduction steps, and here are screenshots after commit:
< 950px
Content admin < 950px

> 950px
Content admin > 950 px

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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