Remove unnecessarily complex logic from tableresponsive.js

Created on 1 June 2014, about 10 years ago
Updated 7 March 2023, over 1 year ago

Problem/Motivation

Issue #1276908: Administrative tables are too wide for smaller screens β†’ added totally amazing responsive table functionality to Drupal 8. The logic in the new tableresponsive.js contains a wildly elaborate approach to removing the display: none from the table cells.

From the original issue, it looks like @jessebeach had concerns about trying to set the display property *back* to display: block or display: table-cell:

I left the code in that removes the display:none regexing. The problem with using a class (instead of $.show and $.hide) to expose the table columns, is the display property of a table cell must be set to table-cell in newer browsers and block in older browsers i.e. IE. And I didn't want to introduce logic to detect support of table-cell, which jQuery seems to do with the $.show method. The regex to pull out the display:none might offend the senses of some, but it's quite legit if not completely pleasing to one's sense of aesthetics.

However rather than trying to set the display property to something else, it'd be much easier just to remove the display: none style using jQuery (http://api.jquery.com/css/).

Setting the value of a style property to an empty string β€” e.g. $( "#mydiv" ).css( "color", "" ) β€” removes that property from an element if it has already been directly applied, whether in the HTML style attribute, through jQuery's .css() method, or through direct DOM manipulation of the style property. It does not, however, remove a style that has been applied with a CSS rule in a stylesheet or

element.

Proposed resolution

Use $.fn.css() instead of custom code.

Remaining tasks

Review.

User interface changes

None.

API changes

None.
πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
JavascriptΒ  β†’

Last updated about 8 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States quicksketch

Live updates comments and jobs are added and updated live.
  • Needs manual testing

    The change/bugfix cannot be fully demonstrated by automated testing, and thus requires manual testing in a variety of environments.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to RTBC over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Tested this manually on Drupal 10 with a standard install.
    Going to the content view and going to mobile size the columns are hidden.
    Triggering show and hide columns works as expected.

Production build 0.69.0 2024