Skip to content

NTNGL-5467 | Enable List Tile Drag and Drop#6973

Open
NicholasHallman wants to merge 14 commits into
mainfrom
NTNGL-5467/tile-mouse-drag-logic
Open

NTNGL-5467 | Enable List Tile Drag and Drop#6973
NicholasHallman wants to merge 14 commits into
mainfrom
NTNGL-5467/tile-mouse-drag-logic

Conversation

@NicholasHallman
Copy link
Copy Markdown
Contributor

@NicholasHallman NicholasHallman commented May 12, 2026

Almost entirely css changes to re-enable drag and keyboard arrangement functionality for tiles.

The rest of the css is for properly positioning the elements and rotating the marker

Functional Tests (Demo Manual QA)

  • Dragging an item to the left edge of the first card and dropping places the element at the front of the tile list
  • Dragging an item to the right edge of the last card and dropping places the element at the end of the list
  • Dragging an item to the left edge of a card in the middle of the list drops it to the left of the drop target
  • Dragging an item to the right edge of a card in the middle of the list drops it to the right of the drop target
  • The drag handle can be focused with the keyboard and splits into two arrows
  • The keyboard can be used to move cards
  • The screen reader properly reads out the new order of the card after moving.
  • Actions are clickable in the title bar
  • With href on or off the drag area extends to the width of the title bar
  • RTL, the marker is in the correct position
  • RTL, keyboard controls place card in the correct position (up, down, home and end)

Highlighting some design decisions we made in the meeting with Glen and Tayzia

  • The up and down arrows work fine for tiles
  • The screen reader announcements and position information is fine for tiles
  • If a tile is draggable it should always have the tile title header

@github-actions
Copy link
Copy Markdown
Contributor

Thanks for the PR! 🎉

We've deployed an automatic preview for this PR - you can see your changes here:

URL https://live.d2l.dev/prs/BrightspaceUI/core/pr-6973/

Note

The build needs to finish before your changes are deployed.
Changes to the PR will automatically update the instance.

Copy link
Copy Markdown
Contributor Author

@NicholasHallman NicholasHallman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Descriptions for what some of this css is accomplishing

}

:host([layout="tile"]) .d2l-list-item-drag-bottom-marker {
right: calc(-0.9rem + 3px);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of magic numbers here but to explain, the -0.9 rem is the gap between the cards and the 3px is half of the 6px that was previously used to center the markers

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spelling this out. I would not be adverse to putting this in a comment for "future-us". I am sure we'll be wondering how we arrived at this down the road.

Comment on lines +350 to +354
:host([layout="tile"]) .d2l-list-item-drag-drop-grid {
display: grid;
grid-template-rows: 100%;
grid-template-columns: 1rem 1fr 1fr 1rem;
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rotates the drop targets

Comment thread components/list/list-item-drag-drop-mixin.js Outdated
Comment thread components/list/list-item-generic-layout.js Outdated
Comment on lines +238 to 243
:host([layout="tile"]:not([is-draggable])) {
grid-template-columns:
[start outside-control-start] 0
[outside-control-end control-start] minmax(0, min-content)
[control-end actions-start] minmax(0, auto)
[actions-end end];
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This varient ensures that the selection box is the left most item when the drag handle isn't present. There's a fun layout issue that prevents minmax(0, min-content) from ever equalling 0. My guess is that this is due to the content below the header spanning this column and so chrome assumes the column can't have a width of 0.

Comment on lines +596 to +598
:host([layout="tile"][draggable]) d2l-selection-input {
margin: auto;
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the drag handle makes the title bar slightly taller so we need to tell the selection to center itself

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the height difference?

Copy link
Copy Markdown
Contributor Author

@NicholasHallman NicholasHallman May 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without the drag handles it's 39px tall, with it's 46px. So 7 pixels

Copy link
Copy Markdown
Contributor

@dbatiste dbatiste May 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glen-bartlett-d2l , @geurts what are your thoughts on this? I wonder if there is any way we can tighten things up so the header doesn't get thicker. Perhaps in this layout, we could render the drag handle differently so it's not quite so tall.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just adding a comment here in case anyone is wondering what is being done with this PR. The PR itself looks fine, but there is some offline discussion happening with regards to:

  1. Are we ok with the aesthetic of the taller tile-header
  2. It looks like we're probably ok for (SC 2.5.8) since it seems like this gets stacked on top of the item's primary click target
  3. Potentially rendering the arrow click targets horizontally instead (if we want to keep the tile header the same height)
image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbatiste If it's not a difficult change, I think rendering the arrow click targets horizontally is the most logical option (we would probably have to change the keyboard functionality and instructions from up-down to left-right too). It solves the grey bar height inconsistency problem, and also the mismatch between the up and down arrows moving tiles right and left in the grid. I think it still looks a bit clunky, especially when there's also a selection box, but it seems to be the best option.

Here's what I think it should look like (not as bad as I originally thought) - Figma

Sorry for the delay! I was agonizing over whether this was a better option than just leaving the grey bar higher for drag and drop (next best option), or trying to reduce the height of the buttons (not a great option, because the 24x24 hit areas have to stay the same, causing even weirder overlaps).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Glen for taking a second look at it, those changes don't look too crazy I should have another pr up by next week, thanks to you both

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should do a separate PR to add an option to d2l-button-move to render the horizontal layout.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: it's not advertised in our index of demo pages, but we have a demo page to assist working on d2l-button-move.

https://live.d2l.dev/BrightspaceUI/core/components/button/demo/button-move.html

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, get that smaller change reviewed and merged in and the rebase it in here. SGTM

@NicholasHallman NicholasHallman marked this pull request as ready for review May 13, 2026 15:39
@NicholasHallman NicholasHallman requested a review from a team as a code owner May 13, 2026 15:39
Comment thread components/list/list-item-drag-drop-mixin.js
Comment thread components/list/list-item-drag-drop-mixin.js Outdated
@NicholasHallman NicholasHallman requested a review from dbatiste May 26, 2026 15:59
Comment thread components/list/list-item-mixin.js Outdated
Comment thread components/list/list-item-placement-marker.js Outdated
Comment thread components/list/list-item-placement-marker.js Outdated
</template>
</d2l-demo-snippet>

<h1>Tile Drag and Drop</h1>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a demo page, but the demo page's h1 is rendered further above. I'd either either just render all h2s (updating the heading text to be tile specific), or I would restructure the headings for all the demos on this page to use h2s and h3s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants