When a path is initially navigated to that heavily includes tabledrag (think Block Layout, or Manage Display). The page is initially viewable with non-JS styles. Then the JavaScript kicks in and modifies the DOM so that the page layout shifts.
This issue is intended to mitigate or remove this jankiness (as much as possible).
Plan
The plan is to use the new at-media scripting feature to reduce the jank as much as possible in browsers that support this. For older browsers, the current behavior will still persist.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | screen-capture (3).gif | 1.14 MB | kostyashupenko |
| #16 | screen-capture (2).gif | 1023.45 KB | kostyashupenko |
| #13 | Снимок экрана 2024-01-15 в 18.51.31.png | 391.27 KB | kostyashupenko |
| tabledrag.mp4 | 723.77 KB | mherchel |
Issue fork drupal-3404215
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
Comment #4
gauravvvv commentedComment #5
smustgrave commentedSeems to follow same solution from #3404218: Table filter creates jank (layout shift) on page load
Tested using Firefox as Chrome doesn't support this yet and verified that the issue appears to be addressed.
Comment #6
quietone commentedI'm triaging RTBC issues. I read the IS and the comments. I didn't find any unanswered questions or other work to do.
Leaving at RTBC.
Comment #7
longwaveWhitespace nitpick.
Comment #8
smustgrave commentedComment #10
viren18febs commentedComment #11
longwaveChrome 120 started supporting this so it feels like this would be good to get in: https://caniuse.com/?search=css-media-scripting
The spellcheck script isn't working, I think this means the MR needs rebasing.
Comment #13
kostyashupenkoKind of tricky task, which requires much more than just scripting media query.
Here is a snippet of only the problem i was able to solve
The snippet above is for selector
.tabledrag-toggle-weight-wrapperonly. Once this element is not created yet by js (but with the help of CSS classdraggable-tableadded to the table we already know our table will be draggable -> we can prevent vertical layout shifting.===========
However for the rest of things:
1. like table column "Weight" which can be hidden/visible based on localStorage
2. also dropbutton links which are expanded by default (while no js)
3. Dragging icon on the left side of each draggable row
-> this is all creates a lot of layout shifting and unfortunately we can not solve these 3 issues just by CSS media scripting query.
Here is more detailed answer.
Regarding column "Weight" - in the initial DOM render we don't know which column exactly should have visible/hide functionality. This is all done by javascript logic and also it is based on localStorage. For example if "Show row weights" button was clicked and then you will refresh the page -> Weight column will be shown by default (based on localStorage). So from CSS we are not able to get the states from localStorage (obviosly) and we don't have selectors we could use for.
Regarding dragging icon on the left side -> same situation. When "Weight" column is shown - we don't have Dragging icon anymore (coz ordering should be handeled by Weight selectbox) and this logic is done on js side and again based on localStorage.
Regarding dropbutton links <- one of the problems we can solve, but it smells like another task where we need to fix first dropbutton links only.
Comment #14
kostyashupenkoAlso current MR https://git.drupalcode.org/project/drupal/-/merge_requests/5782 doesn't doing anything, since className `.tabledrag-hide` appears from JS. Moreover we can't just use `display: none;` here, because if "Show row weights" button was pressed -> Weight column should be visible by default.
Comment #15
longwaveRemoving Novice tag following #13.
Comment #16
kostyashupenkoRegarding my message #13 i see dropbutton links already were fixed & closed in https://www.drupal.org/project/drupal/issues/3361315
Here is my attempt to fix vertical layout shifting and a workaround of "Show row weights" functionality. Previously this button (Show row weights) was added from javascript which creates visual layout shifting (see before/after patch videos below). I decided to change logic a bit, see merge request.
Before patch:

After patch:

Changing status of the ticket to "Needs review" just to bump this issue & discuss this task more carefully. However the fix i provided is not enough to close this ticket, since the biggest layout shifting creates "Weight" column (see explanation #13)
Comment #17
djsagar commentedReplicated same issue and applied MR !5782 but issue is still remain so moving this to NW.