[later phase] [needs design] Component drag handle

Created on 12 July 2024, 5 months ago
Updated 18 September 2024, 2 months ago

Overview

There's an additional drag handle which is visible when a component is active that ensures users always have a consistent way to drag a component. When the drag handle is hovered, a "grab" cursor should be visible. User would still be allowed to drag components by just grabbing component from anywhere, but when they hover components outside the handle, they would see the "default" cursor. When user drags component using the drag handle, the user should be able to move the component and all components nested inside it.

User interface changes

Feature request
Status

Postponed

Component

Page builder

Created by

🇫🇮Finland lauriii Finland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @lauriii
  • 🇬🇧United Kingdom jessebaker

    A technical challenge here is that the drag handle will be rendered outside of the iFrame but the element being dragged is inside the iFrame.

    I believe this can be achieved by making the handle a sortableJS list of 1 item (the currently selected component) and clever configuration of the group property to ensure it can be dragged from and dropped into the main sortableJS list inside the iFrame. Further to that, the component being dragged will have to be manually hidden on dragStart and then probable removed on drop.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    This is definitely a front-end issue, not a back-end one 😅 (And from the sounds of #2, a pretty tricky one! 😳)

  • Assigned to fazilitehreem
  • Pipeline finished with Failed
    4 months ago
    Total: 164s
    #231729
  • Issue was unassigned.
  • Status changed to Needs review 4 months ago
  • Status changed to Needs work 4 months ago
  • 🇫🇮Finland lauriii Finland

    Thank you for working on this @fazilitehreem! 💯

    Something I noticed as part of the video you posted was that the top-level components (i.e. section) drag handle was rendered inside the canvas. However, according to the designs, the drag handle should be rendered outside the canvas in this scenario:

    It looks like there's some additional spacing inside the canvas which may need to be removed as part of this issue for this to work.

  • 🇬🇧United Kingdom jessebaker

    @lauriii

    Something I noticed as part of the video you posted was that the top-level components (i.e. section) drag handle was rendered inside the canvas.

    I suspect that what you are describing is specific to the "design" of the placeholder components in the mocked preview data and won't be a problem once we have a real set of components.

    The handle is positioned relative to the outline, overlayed above the canvas iframe and would be outside the canvas if the component extended all the way across.

    It looks like there's some additional spacing inside the canvas which may need to be removed as part of this issue for this to work.

    The spacing inside the canvas again is dependent on the design of the site being previewed so I don't think should be addressed as part of this.

  • Status changed to Needs review 4 months ago
  • 🇫🇮Finland lauriii Finland

    Ah, I didn't realize this was looking the way that it does because the components are implemented in this way. Makes sense! 👍

  • 🇬🇧United Kingdom jessebaker

    Thanks for your efforts so far @fazilitehreem - I've left a review on the MR.

  • Status changed to Needs work 4 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺
  • Assigned to utkarsh_33
  • I'll try to implement the approach suggested(without injecting it into iFrame) in a seperate MR.Assigning it to me.

  • Utkarsh_33 changed the visibility of the branch 3461035-add-draghandle-as-outline's-child to hidden.

  • Utkarsh_33 changed the visibility of the branch 3461035-implement-draghandle-new to hidden.

  • Utkarsh_33 changed the visibility of the branch 3461035-implement-draghandle-new to active.

  • Merge request !139Draft: Wip → (Closed) created by utkarsh_33
  • 🇮🇳India HungerGames07

    I tried something like this, the user can drag the component using the drag handle, and the cursor changes appropriately. The nested components move along with the main component.

    document.addEventListener('DOMContentLoaded', () => {
    const component = document.getElementById('component1');
    const dragHandle = component.querySelector('.drag-handle');

    let offsetX, offsetY;
    let isDragging = false;

    dragHandle.addEventListener('mousedown', (e) => {
    isDragging = true;
    offsetX = e.clientX - component.getBoundingClientRect().left;
    offsetY = e.clientY - component.getBoundingClientRect().top;
    document.addEventListener('mousemove', onMouseMove);
    document.addEventListener('mouseup', onMouseUp);
    });

    function onMouseMove(e) {
    if (isDragging) {
    component.style.left = `${e.clientX - offsetX}px`;
    component.style.top = `${e.clientY - offsetY}px`;
    }
    }

    function onMouseUp() {
    isDragging = false;
    document.removeEventListener('mousemove', onMouseMove);
    document.removeEventListener('mouseup', onMouseUp);
    }
    });

  • 🇬🇧United Kingdom jessebaker

    @Utkarsh_33 - I have taken your WIP MR and added another commit - basically I have roughly implemented what I suggested in #2. It is definitely not a finished piece of work, but hopefully it's enough to allow you to build on top of it!

  • Issue was unassigned.
  • I am not currently working on this issue so unassigning it for me.

  • Assigned to jessebaker
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    @jessebaker I hear it was decided yesterday that @Utkarsh_33 should not continue here. Why is that? I thought you just got him going with #18? 🤔

  • 🇬🇧United Kingdom jessebaker

    Unfortunately, @Utkarsh_33 hit another issue with implementing the required UX and I have no idea how to proceed either without taking a lot of time to investigate or potentially going back to the UX team to re-think this interaction.

    This isn't on the critical path for the Drupalcon demo so I think time is better spent on other, more pressing, issues hence asking him to move on.

    The button adjacent to the containers is not the part of sortable list in the screenshots.
    So when we drag the button in the swimlane parallel to the sortable list it does not reorder the sections.It only re-orders them when we drag the button inside the red-line border for the sortable list.I have recorded the video explaining the issue. - @Utkarsh_33

    I've attached the Video that Utkarsh made which I think clarifies the issue well.

  • Issue was unassigned.
  • 🇬🇧United Kingdom jessebaker

    Unassigning from me in case someone else wants to take a look!

  • Assigned to lauriii
  • Status changed to Postponed 4 months ago
  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Per #21, signaling this needs product input (potentially design changes), and currently should not be worked on.

  • 🇫🇮Finland lauriii Finland

    Demoting to major since this is not on the critical path. I'll keep this assigned to me because I'd like to ask a designer if there are alternative approaches we could take to avoid this challenge.

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    👍

  • 🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

    Not actionable yet, so removing from https://contribkanban.com/board/experience_builder.

Production build 0.71.5 2024