Problem/Motivation

Right now, every element in a draggable table's first cell (this is where the drag-handle and the indentation are added) are floated to right (or to left for RTL languages). This makes the hierarchy of the taxonomy terms hard to follow, and besides that it is almost impossible to change the level of those taxonomy terms thats drag-handle is rendered on the left (RTL: right) side of the table cell (because of the high number of the preceding indentation elements).

Screenshots about the current output:

Taxonomy overview page with hierarchy on Seven theme Taxonomy overview page with hierarchy on Claro theme

Steps to reproduce

  1. Install Drupal with the Standard profile
  2. Add about 10 taxonomy term to the 'Tags' vocabulary.
  3. Adjust the same taxonomy term hierarchy as on the attached screenshots.
  4. Check the overview page of the 'Tags' vocabulary with a smaller browser window width.

Proposed resolution

Proposed look for a taxonomy overview page with hierarchy on Claro theme

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#52 3083044-51.patch6.92 KBGauravvvv
#51 interdiff-50_51.txt4.68 KBGauravvvv
#51 3083044-51.patch7.79 KBGauravvvv
#50 3083044-50.patch6.96 KBGauravvvv
#36 ie-patch-35.PNG44.9 KBAntoniya
#35 Flex-basis__labels-wrap__column-widths-wrong.png292.76 KBbnjmnm
#35 Display-Flex__labels-not-wrap.png361.67 KBbnjmnm
#35 interdiff__30-35.txt595 bytesbnjmnm
#35 3083044__35.patch3.48 KBbnjmnm
#33 rtl-ie.PNG38.05 KBAntoniya
#33 rtl-edge.PNG50.08 KBAntoniya
#33 ie-seven.PNG38.26 KBAntoniya
#33 edge-seven.PNG48.76 KBAntoniya
#32 edgetx.PNG35.4 KBAntoniya
#31 firefox.png71.44 KBAntoniya
#30 interdiff_25-28.txt16.32 KBbnjmnm
#30 3083044-28.patch3.31 KBbnjmnm
#28 interdiff_81-86.txt1.13 KBbnjmnm
#28 3082672-86.patch47.34 KBbnjmnm
#26 IE11.png183.31 KBbnjmnm
#26 firefox.png183.42 KBbnjmnm
#26 safari.png127.29 KBbnjmnm
#25 firefox.png183.42 KBbnjmnm
#25 changed-marker-floats-around.png162.34 KBbnjmnm
#25 3083044-25.patch17.27 KBbnjmnm
#25 interdiff_23-25.txt3.13 KBbnjmnm
#23 Screen Shot 2020-08-19 at 1.35.07 PM.png102.38 KBbnjmnm
#23 3083044-23.patch16.45 KBbnjmnm
#23 interdiff_17-23.txt530 bytesbnjmnm
#20 Screenshot 2020-08-18 at 18.05.46.png28.73 KBlauriii
#17 3083044-17.patch16.21 KBbnjmnm
#17 interdiff_15-17.txt2.44 KBbnjmnm
#16 Screen Recording 2020-08-13 at 14.23.09.gif3.08 MBlauriii
#15 interdiff_13-15.txt2.1 KBbnjmnm
#15 3083044-15.patch14.7 KBbnjmnm
#13 3083044-13.patch12.6 KBbnjmnm
#13 interdiff_11-13.txt12.28 KBbnjmnm
#11 3083044-11.patch3.89 KBbnjmnm
#11 interdiff_8-11.txt7.14 KBbnjmnm
#8 3083044-8.patch8.06 KBbnjmnm
#8 interdiff_5-8.txt507 bytesbnjmnm
#6 Screen Recording 2020-08-02 at 10.21.36.gif4.21 MBlauriii
#5 3083044-5-REROLL.patch8.04 KBbnjmnm
#4 longterm-RTL.png29.17 KBbnjmnm
#4 longterm.png34.49 KBbnjmnm
#4 3083044-4.patch8.15 KBbnjmnm
Taxonomy-hierarchy--Claro--proposed.png214.28 KBhuzooka
Taxonomy-hierarchy--Claro.png212.59 KBhuzooka
Taxonomy-hierarchy--Seven--now.png215.57 KBhuzooka
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

huzooka created an issue. See original summary.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

bnjmnm’s picture

Status: Active » Needs review
FileSize
8.15 KB
34.49 KB
29.17 KB

Here's a first patch. This addresses the issue and indirectly addresses #197641: Drag and drop is not RTL aware as well, due to some RTL logic changes needed in this scope.

Note that Claro will be addressed in #3083051: Refactor tabledrag when core issues are resolved

bnjmnm’s picture

Needed a reroll

lauriii’s picture

I'm wondering how should we communicate the hierarchy after the table runs out of space. The behavior of the current patch seems confusing since it's pushing the items to left which makes those items look like they are not a child of their parent. I attached a gif to demonstrate this.

lauriii’s picture

It seems like in Claro #6 is solved so that the table doesn't shrink. This could work in combination with #3068696: Tables overflow on mobile but I'm not sure how to solve this for Seven. Maybe we could implement this based on how Claro has implemented this, and open a follow-up to improve this in Seven.

bnjmnm’s picture

Good catch in #7. The patch was based on Claro's approach, but it looks like the indent elements in Seven aren't consistently adhering to the width: 20px; style. Setting min-width: 20px; solves this.

bnjmnm’s picture

lauriii’s picture

Status: Needs review » Needs work
  1. +++ b/core/misc/tabledrag.es6.js
    @@ -207,14 +207,15 @@
    +        '<tr><td><div class="tabledrag-cell-content"></div></td></tr>',
    

    Shouldn't we generate the test row using the theme function?

  2. +++ b/core/misc/tabledrag.es6.js
    @@ -207,14 +207,15 @@
    +        .find('.tabledrag-cell-content')
    
    @@ -1655,7 +1663,9 @@
         const marker = Drupal.theme('tableDragChangedMarker');
    

    Wouldn't it be more consistent to use data-drupal-selector here too?

  3. +++ b/core/misc/tabledrag.es6.js
    @@ -502,6 +504,10 @@
    +    $item
    +      .find('td:first-of-type')
    +      .wrapInner($(Drupal.theme('tableDragCellItemsWrapper')));
    

    I think this change (including the CSS rules attached to the element) is a bit risky because this could break custom styles or JavaScript. I'm not sure how to solve this without risk of having regressions on some sites.

bnjmnm’s picture

Status: Needs work » Needs review
FileSize
7.14 KB
3.89 KB

I swear I'd already tried this approach before, but it seems to be working with a patch half the size of the previous one.... None of the changes reviewed in #10 are there as they're not needed with this approach. Tested in IE, RTL, nested tables and it all seems fine?
The BC concerns mentioned in #10.3 is how Claro currently addresses the line break issue. If the solution here works, we'll be able to eliminate the BC risks in #3083051: Refactor tabledrag when core issues are resolved. 🤞

Status: Needs review » Needs work

The last submitted patch, 11: 3083044-11.patch, failed testing. View results

bnjmnm’s picture

Status: Needs work » Needs review
FileSize
12.28 KB
12.6 KB

The test failure in #12 was because the location of the "changed" marker is changed in this patch. Having it appear between the tabledrag handle and label makes it possible to consistently control the width between all the elements. In its prior position, its distance from the label varies depending on the amount of text wrapping within the label.

While addressing this, it occurred to me that the approach as-is could cause problems for themes extending Stable/Stable9, as their CSS would not necessarily be equipped for the JavaScript related DOM changes. To get around this, the JS adds new (BEM friendly) selectors that receive the styling related to this fix. Because these selectors are new, they can be added to the Stable themes since they aren't altering any existing styles.

Status: Needs review » Needs work

The last submitted patch, 13: 3083044-13.patch, failed testing. View results

bnjmnm’s picture

Status: Needs work » Needs review
FileSize
14.7 KB
2.1 KB

The classes added in #13 broke some xpath selectors in some tests. This should take care of that.

lauriii’s picture

Status: Needs review » Needs work
FileSize
3.08 MB

Tested this on Seven and seems like this doesn't work as well as #8 did. The last item is not displayed at current indentation and when dragging rows the handle disappears.

bnjmnm’s picture

Status: Needs work » Needs review
FileSize
2.44 KB
16.21 KB

Re #16

The last item is not displayed at current indentation

. Looks like this is due to the test indents being added to separate lines. Once I updated the <td> holding the indents to display:flex, this fixed it.

when dragging rows the handle disappears

Looks like this is a pre-existing problem when .touchevents is present. Since the .drag state changes the background position of the handle, I suspect this image used to be a sprite, and when it was changed to svg, the .touchevents use case was not addressed. I chose to address here as it's needed to for manual testing, and I the benefits of a non-vanishing drag handle need to be delayed. Specific concerns about the implementation of the fix can be addressed in a followup if need be.

Status: Needs review » Needs work

The last submitted patch, 17: 3083044-17.patch, failed testing. View results

bnjmnm’s picture

Status: Needs work » Needs review

Test fail was unrelated and in a test known to intermittently fail. Back to NR

lauriii’s picture

Issue summary: View changes
Status: Needs review » Needs work
FileSize
28.73 KB

The last row is still rendered so that its depth could be confusing 😓

huzooka’s picture

It's time to stop reinventing the wheel (flex-whatever things) and do what Claro does ☺️

lauriii’s picture

@huzooka problem with the Claro approach is that it requires a BC breaking markup change. We've tried to find approach that would be less disruptive.

bnjmnm’s picture

Status: Needs work » Needs review
FileSize
530 bytes
16.45 KB
102.38 KB

Fixes #20 by bringing back a min-width that was unintentionally removed during the trial and error to find a BC friendly solution.

lauriii’s picture

Status: Needs review » Needs work
Issue tags: +Needs release note

Tested this manually and the deeply nested tabledrags were working as expected at least on Chrome 👌Would be good idea to confirm with other browsers too before committing this.

  1. +++ b/core/misc/tabledrag.es6.js
    @@ -477,11 +478,12 @@
         // Add a class to the title link.
         $item
           .find('td:first-of-type')
    +      .addClass('draggable__first-cell')
           .find('a')
           .addClass('menu-item__link');
    

    I think we should try to find a way to get rid of this in a follow-up.

  2. +++ b/core/misc/tabledrag.es6.js
    @@ -1655,7 +1657,7 @@
    -      cell.append(marker);
    +      cell.find('[data-drupal-draggable-handle-wrapper]').after(marker);
    
    @@ -1690,7 +1692,7 @@
    -        return `<abbr class="warning tabledrag-changed" title="${Drupal.t(
    +        return `<abbr class="warning tabledrag-changed tabledrag-changed--before-label" title="${Drupal.t(
    

    Aren't these changes out of scope?

  3. +++ b/core/misc/tabledrag.es6.js
    @@ -1700,7 +1702,7 @@
    -        return '<div class="js-indentation indentation">&nbsp;</div>';
    +        return '<div class="js-indentation indentation draggable__indentation">&nbsp;</div>';
    

    I'm +1 for using more specific class names in general. Wondering why do we need draggable__indentation in the scope of this issue?

  4. +++ b/core/modules/system/css/components/tabledrag.module.css
    @@ -47,6 +50,9 @@ a.tabledrag-handle:hover .handle,
    +  min-width: calc(2em + 14px);
    

    Where does 2em + 14px come from?

  5. +++ b/core/themes/stable9/css/system/components/tabledrag.module.css
    @@ -20,6 +20,9 @@ tr.region-populated {
    +.draggable__first-cell {
    +  display: flex;
    +}
    

    This seems potentially something that could have an impact on some themes. Let's at least write a release note to let themes know they should specifically test table drags when they update.

bnjmnm’s picture

#24.1 & 3: .draggable__first-cell and .draggable__indentation were added so Stable/Stable9 could get these new styles without breaking the Stable promise, especially since there was an opportunity to use more specific classnames.

#24.2 I felt these changes were needed as the changed marker can't be consistently positioned when it's on the wrapping-side of the drag label. This approach was implemented in Claro to address the same symptom.

#24.4 Added comment to explain the 2em + 14px

#24.5 Updated the existing CR since its contents are no longer applicable since we shifted to the BC friendly approach.

bnjmnm’s picture

Status: Needs work » Needs review
FileSize
127.29 KB
183.42 KB
183.31 KB

Uploading screenshots here as D.O. got sick of me uploading in #25

As the screenshot may indicate, I opted for a graceful degradation with IE11. If the table cell is set to display: flex; the table becomes less accommodating with narrow viewports. As it turns out, the bug this issue addresses does not occur in HEAD with IE11 anyway, so there's no regression.

lauriii’s picture

Category: Feature request » Bug report
Status: Needs review » Needs work
Issue tags: +Needs followup

Re #24.1 & 3 The approach you proposed is nice because it provides a safer way to include these changes in Stable. However, I think it's fine to fix this only in system module so we don't risk having regressions on sites extending Stable. This could be something like .draggable td:first-of-type { display: flex; } in system module.

Re #24.2 Let's open a follow-up for figuring out what to do with the changed marker. I think for now we shouldn't change it because a) I think it could use bigger design change than just the position of the asterisk b) it seems like this would only happen in the same edge cases where tabledrags would have rendered awkwardly before this change meaning that it's not a regression.

bnjmnm’s picture

Status: Needs work » Needs review
Issue tags: -Needs followup
FileSize
47.34 KB
1.13 KB

I'm fully convinced by the rationale of both points in #27.

The approach I previously had for adding the changes was only needed when the JavaScript altered the DOM structure. Now that I've found an approach that doesn't require DOM changes, the fix can be in the system module CSS, which is already fenced away by Stable. This eliminates the need for almost all of the JS changes, too.

With the changed marker, I also suspected this was out of scope but wasn't sure if it would be perceived as a regression. It was pointed out that the only behavior that would cause the variable change marker distance is :
1) Unlikely to happen in themes other than Claro (which has its own fix for this anyway)
2) Actually existing behavior, it's just masked by the much worse symptoms addressed by this patch.
I've created a followup for that #3166623: [PP-1] Make tabledrag changed marker consistiently postioned from it's label

lauriii’s picture

Status: Needs review » Needs work

Seems like there are some unrelated changes in the patch 🤔

bnjmnm’s picture

Status: Needs work » Needs review
FileSize
3.31 KB
16.32 KB

Wrong patch in #28

Antoniya’s picture

FileSize
71.44 KB

This is looking great in Firefox & Safari as well:

firefox screenshot

Will test on Edge/IE tomorrow.

Antoniya’s picture

FileSize
35.4 KB

A final test in Edge & IE shows no issues/bugs:

Edge screenshot

Yay! Thank you for fixing this 🎉

Antoniya’s picture

FileSize
48.76 KB
38.26 KB
50.08 KB
38.05 KB

Oops, Claro already has a fix for this 🙈

Tested with Seven on all browsers, only IE seems to be missing the display: flex; rule which makes the term hierarchy practically invisible 😕 Adding the rule to the <td> tags aligns the indentation divs nicely so I guess that's the only thing left to fix?

IE bug

Tested RTL as well (thanks for the reminder @laurii), didn't notice any issues (apart from the one shown above).

Antoniya’s picture

Status: Needs review » Needs work
bnjmnm’s picture

Good catch in #33 @Antoniya!. It is intentional to not provide the improvements in this patch due to IE11, but the IE11 experience should not be worsened as a result. This patch should address that.

IE11 has a hard time dealing with Flex items inside a table. If the table row has display: flex the label won't wrap at all, which is still beneficial as it helps with the more common occurrence of labels wrapping to a second line, eliminating the need to horizontally scroll to access all parts of the table. A third line is less likely

There is a workaround to make these IE flex items in a table wrappable by explicity setting a child's flex-basis, but this prevents the table from properly calculating column widths

Because of this, my approach is to not provide this fix in IE11, but to also be sure the experience isn't made worse. Between the usage statistics for IE11 and this being a somewhat uncommon scenario, I think this is a good candidate for graceful degradation.

Antoniya’s picture

FileSize
44.9 KB

@bnjmnm I understand, flexbox in IE is a nightmare lol

I tested the latest patch in #35 and I can confirm that it's a nice improvement to all major browsers and it also introduces no regressions in IE AFAICS (hierarchy is clearly visible):

IE screenshot

Thank you! 👏

Antoniya’s picture

Status: Needs review » Reviewed & tested by the community

Marking as reviewed even though it would be nice if someone else also tested manually.

  • lauriii committed c2bcd73 on 9.1.x
    Issue #3083044 by bnjmnm, Antoniya, lauriii, huzooka: Prevent line...
lauriii’s picture

Status: Reviewed & tested by the community » Fixed

Tested manually with Chrome, Firefox, Safari, Edge, IE 11, Chrome for Android and Safari for iOS and the behaviour was as expected 👌I don't think we can add test coverage for this since this is only a visual change.

Committed c2bcd73 and pushed to 9.1.x. Thanks!

lauriii’s picture

Opened #3169872: Table cells not aligned properly vertically which seems to be caused by this.

  • lauriii committed 15a42d7 on 9.1.x
    Revert "Issue #3083044 by bnjmnm, Antoniya, lauriii, huzooka: Prevent...
lauriii’s picture

Status: Fixed » Needs work

Reverted this because of the regressions documented in #3169872: Table cells not aligned properly vertically.

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

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

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.

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.

quietone’s picture

What needs to be done here? Can we get an IS update to identify the next steps? Adding tag.

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.

Gauravvvv’s picture

Status: Needs work » Needs review
FileSize
6.96 KB

I have created a patch for same, also handled table cells alignment. please review

Gauravvvv’s picture

Gauravvvv’s picture

FileSize
6.92 KB

Fixed the failures of patch #50

Status: Needs review » Needs work

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