Skip to content

Commit

Permalink
Fixed #6033 - A drop indicator doesn't appear when dropping a questio…
Browse files Browse the repository at this point in the history
…n between two custom widgets
  • Loading branch information
tsv2013 committed Nov 11, 2024
1 parent 50a2843 commit 98a79d0
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/survey-creator-angular/src/question-widget.component.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
<ng-template #template>
<div *ngIf="adorner" class="svc-question__adorner" [class]="adorner.rootCss()" (mouseover)="adorner.hover($event, $event.currentTarget)" (mouseleave)="adorner.hover($event, $event.currentTarget)" [attr.data-sv-drop-target-survey-element]="adorner.element.name || null">
<div *ngIf="adorner.element.isInteractiveDesignElement" class="svc-question__content" [class]="adorner.css()" [key2click] (click)="adorner.select(adorner, $event)" data-bind="clickBubble: false" #container>
<div *ngIf="adorner" class="svc-question__adorner" [class]="adorner.rootCss()"
(mouseover)="adorner.hover($event, $event.currentTarget)" (mouseleave)="adorner.hover($event, $event.currentTarget)"
[attr.data-sv-drop-target-survey-element]="adorner.element.name || null">
<div *ngIf="adorner.element.isInteractiveDesignElement" class="svc-question__content" [class]="adorner.css()"
[key2click] (click)="adorner.select(adorner, $event)" data-bind="clickBubble: false" #container>
<div class="svc-question__drop-indicator svc-question__drop-indicator--left"></div>
<div class="svc-question__drop-indicator svc-question__drop-indicator--right"></div>
<div class="svc-question__drop-indicator svc-question__drop-indicator--top"></div>
<div class="svc-question__drop-indicator svc-question__drop-indicator--bottom"></div>
<div *ngIf="adorner.allowDragging" class="svc-question__drag-area" (pointerdown)="adorner.onPointerDown($event)">
<svg class="svc-question__drag-element" [iconName]="'icon-drag-area-indicator_24x16'" [size]="24" sv-ng-svg-icon></svg>
<svg class="svc-question__drag-element" [iconName]="'icon-drag-area-indicator_24x16'" [size]="24"
sv-ng-svg-icon></svg>
</div>
<div class="svc-widget__content">
<ng-template [component]="{ name: componentName, data: componentData }"></ng-template>
</div>
<div *ngIf="adorner.isEmptyElement" class="svc-panel__placeholder_frame">
<div class="svc-panel__placeholder" data-bind="text: placeholderText"></div>
</div>
<div class="svc-panel__placeholder" data-bind="text: placeholderText"></div>
</div>
<div class="svc-question__content-actions">
<sv-action-bar [model]="adorner.actionContainer" [handleClick]="false"></sv-action-bar>
</div>
Expand Down
4 changes: 4 additions & 0 deletions packages/survey-creator-knockout/src/question-widget.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
data-bind="css: rootCss(), attr: { 'data-sv-drop-target-survey-element': element.name }, event: { mouseover: function(m, e) { hover(e, $element); }, mouseleave: function(m, e) { hover(e, $element); } }">
<!-- ko if: question.isInteractiveDesignElement -->
<div class="svc-question__content" data-bind="click: koSelect, key2click, clickBubble: false, css: css()">
<div class="svc-question__drop-indicator svc-question__drop-indicator--left"></div>
<div class="svc-question__drop-indicator svc-question__drop-indicator--right"></div>
<div class="svc-question__drop-indicator svc-question__drop-indicator--top"></div>
<div class="svc-question__drop-indicator svc-question__drop-indicator--bottom"></div>
<!-- ko if: allowDragging -->
<div class="svc-question__drag-area"
data-bind="visible:allowDragging, event: {pointerdown: (model, event)=>{onPointerDown(event)}}">
Expand Down
12 changes: 12 additions & 0 deletions packages/survey-creator-vue/src/adorners/CustomWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
@click="model.select(model, $event)"
data-bind="clickBubble: false"
>
<div
class="svc-question__drop-indicator svc-question__drop-indicator--left"
></div>
<div
class="svc-question__drop-indicator svc-question__drop-indicator--right"
></div>
<div
class="svc-question__drop-indicator svc-question__drop-indicator--top"
></div>
<div
class="svc-question__drop-indicator svc-question__drop-indicator--bottom"
></div>
<div
v-if="model.allowDragging"
class="svc-question__drag-area"
Expand Down
23 changes: 23 additions & 0 deletions visualRegressionTests/tests/designer/drag-drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -755,3 +755,26 @@ test("Drag Drop to collapsed page", async (t) => {
await takeElementScreenshot("drag-drop-in-collapsed-page.png", ".svc-tab-designer_content", t, comparer);
});
});

fixture`DragDrop custom widget Screenshot`.page`http://127.0.0.1:8080/testCafe/testcafe-widget.html`.beforeEach(async (t) => {
});

test("Drag indicator for custom widget", async (t) => {
await wrapVisualTest(t, async (t, comparer) => {
await t.resizeWindow(1252, 900);

const json = {
elements: [{ type: "bootstrapdatepicker", name: "q1" }, { type: "bootstrapdatepicker", name: "q2" }]
};
await setJSON(json);

await patchDragDropToDisableDrop();

const q1 = Selector("[data-sv-drop-target-survey-element='q1']");
await t
.hover(RatingToolboxItem)
.dragToElement(RatingToolboxItem, q1, { speed: 0.5, offsetX: 100, offsetY: 10 });

await takeElementScreenshot("drag-drop-over-custom-widget.png", Selector(".svc-page").nth(0), t, comparer);
});
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 98a79d0

Please sign in to comment.