Skip to content

feat: GAUD-10642 mobile drag n drop - #7510

Open
EdwinACL831 wants to merge 9 commits into
mainfrom
ecollazos/GAUD-10642_mobile_drag_n_drop
Open

EdwinACL831 wants to merge 9 commits into
mainfrom
ecollazos/GAUD-10642_mobile_drag_n_drop

Conversation

@EdwinACL831

@EdwinACL831 EdwinACL831 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Jira

GAUD-10642

Description

⚠️ Attention, this only is for MOBILE!! ⚠️

This is something that happens when using draggable list items from a mobile device. We mimic the drag and drop behavior for them, specially the scrolling. This would only work if the items' scrolling parent is the document itself (a.k.a. browser view port). Therefore, we wanted to enable those draggable items to work fine within a different scrolling container (i.e., side-nav panel).

This PR attempts to address that by mimicking the HTML5 native drap-n-drop API. To achieve this now by:

  • Finding the closest scrollable parent/ancestor container (if no container, then adds it to the html body element itself).
  • Adding the touch-action: none inline style to the nearest scrollable parent found.
  • making the scroll behavior programmatically as it has been the case before too.

This is also guarded by a Feature Flag:

@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-7510/

Note

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

const dropTargetLeaveDelay = 1000; // ms
const touchHoldDuration = 400; // length of time user needs to hold down touch before dragging occurs
const scrollSensitivity = 150; // pixels between top/bottom of viewport to scroll for mobile
const scrollContainerSensitivity = 60; // pixels between top/bottom of scrollable container to scroll for mobile

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.

IMHO I think it makes sense to have a smaller threshold to know when to start scrolling, since the scrolling container size is something we cannot control, therefore by making this small we are making sure that the user wants to scroll within that container...

}

#scrollableContainer;
#touchAction = '';

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.

Since we are setting this touch-action to be none, we still want to revers it to how it was in case there was an existing touch-action value before.

this._currentTouchListItem = listItem;
}

if (this.#improvedMobileScroll) this.#doScroll(touch);

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.

I figure that we actually want to scroll first and then search for a droppable zone. That is because there this very edge-case where the draggable items are really big so just one a time can be displayed (I know this would be also a horrible UX). So at least the user could scroll up/down to find droppable zones in those cases.


#doScroll(touch) {
if (!touch || !this.#scrollableContainer) return;
if (this.#scrollableContainer === document.body) {

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.

So if the scrollable container is the body itself, we need to scroll the view port instead of the body itself.

return listNode.shadowRoot.elementFromPoint(x, y);
}

_findListItemScrollableContainer(listItem) {

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.

No sure if also this should have been using the # notation instead of the _

@EdwinACL831
EdwinACL831 marked this pull request as ready for review September 22, 2026 14:07
@EdwinACL831
EdwinACL831 requested a review from a team as a code owner September 22, 2026 14:07
@EdwinACL831
EdwinACL831 force-pushed the ecollazos/GAUD-10642_mobile_drag_n_drop branch from 8cfbb46 to ab0fcc4 Compare September 22, 2026 14:10
@EdwinACL831 EdwinACL831 changed the title GAUD-10642 mobile drag n drop feat: GAUD-10642 mobile drag n drop Sep 22, 2026
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.

1 participant