Skip to content

Commit

Permalink
#5980 Hide toolbox submenu on unhover button (#5984)
Browse files Browse the repository at this point in the history
* #5980 Hide toolbox submenu on unhover button
Fixes #5980

* #5980 update screenshots

* #5980 fix hover button styles in rtl

* #5980 - update screenshots

* #5980 - update screenshots

* #5980 - fixed postcss

* fix toolbox subtype paddings

* fixed item group event bindings #5980
  • Loading branch information
novikov82 authored Oct 28, 2024
1 parent e4e997a commit d40411b
Show file tree
Hide file tree
Showing 36 changed files with 53 additions and 57 deletions.
6 changes: 6 additions & 0 deletions functionalTests/designer/toolbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,12 @@ test("toolbox subTypes: add items by drag-n-drop", async (t) => {
.hover(getToolboxItemByText("Rating Scale").parent(".svc-toolbox__tool").find(".svc-toolbox__item-submenu-button"))
.wait(400)
.expect(toolboxSubTypesPopup.visible).ok()
.hover(getToolboxItemByText("Rating Scale").parent(".svc-toolbox__tool"))
.wait(400)
.expect(toolboxSubTypesPopup.visible).notOk()
.hover(getToolboxItemByText("Rating Scale").parent(".svc-toolbox__tool").find(".svc-toolbox__item-submenu-button"))
.wait(400)
.expect(toolboxSubTypesPopup.visible).ok()

.hover(getSubToolboxItemByText("Smileys"), { speed: 0.1 })
.wait(400)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<ng-template #template>
<svc-toolbox-item [model]="item" [viewModel]="viewModel" [creator]="creator" [isCompact]="isCompact"></svc-toolbox-item>
<div class="svc-toolbox__item-submenu-button" (mouseover)="viewModel.onMouseOver(item, $event)">
<div class="svc-toolbox__item-submenu-button" (mouseover)="viewModel.onMouseOver(item, $event)"
(mouseleave)="viewModel.onMouseLeave(item, $event)">
<svg [iconName]="item.subitemsButtonIcon" [size]="16" sv-ng-svg-icon></svg>
<sv-ng-popup [popupModel]="model.popupModel" [getArea]="model.getArea"></sv-ng-popup>
</div>
<sv-ng-popup [popupModel]="model.popupModel" [getArea]="model.getArea"></sv-ng-popup>
</ng-template>
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
<div [class]="itemCssClasses">
<div class="svc-toolbox__category-separator" *ngIf="item.needSeparator && !creator.toolbox.showCategoryTitles">
</div>
<div class="svc-toolbox__tool-content sv-action__content" (pointerdown)="model.onPointerDown($event)"
(mouseover)="model.onMouseOverTool(item, $event)"
(mouseleave)="model.onMouseLeave(item, $event)">
<div class="svc-toolbox__tool-content sv-action__content" (pointerdown)="model.onPointerDown($event)">
<ng-template [component]="{ name: model.itemComponent, default: 'svc-toolbox-item',
data: { model: item, viewModel: model, creator: creator, isCompact: isCompact } }"></ng-template>
</div>
Expand Down
3 changes: 2 additions & 1 deletion packages/survey-creator-core/creator-themes-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ var themeConstants = {
"--ctr-toolbox-scrollbar-right": "0",
"--ctr-toolbox-scroller-align-items": "flex-start",
"--ctr-toolbox-item-submenu-button-right": "8px",
"--ctr-toolbox-item-submenu-button-top": "12px",
"--ctr-toolbox-item-align": "stretch",
"--ctr-toolbox-submenu-offset": "13px",
"--ctr-toolbox-submenu-offset": "20px",
"--ctr-toolbox-width-compact": "72px",
"--ctr-toolbox-margin-left-compact": "0px",
"--ctr-toolbox-separator-width": "208px",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
}
}
.svc-toolbox__item-submenu-button {
svg {
transform: rotate(180deg);
}
}
}
.svc-creator__toolbox--right {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@
border-top-color: transparent;
border-inline-end-color: transparent;
box-shadow:
var(--ctr-tooltip-shadow-1-offset-x, 0px) var(--ctr-tooltip-shadow-1-offset-y, 2px)
var(--ctr-tooltip-shadow-1-blur, 6px) var(--ctr-tooltip-shadow-1-spread, 0px)
var(--ctr-tooltip-shadow-1-color, rgba(0, 0, 0, 0.1)),
var(--ctr-tooltip-shadow-2-offset-x, 0px) var(--ctr-tooltip-shadow-2-offset-y, 1px)
var(--ctr-tooltip-shadow-2-blur, 2px) var(--ctr-tooltip-shadow-2-spread, 0px)
var(--ctr-tooltip-shadow-2-color, transparent);
var(--ctr-tooltip-shadow-1-offset-x, 0px) var(--ctr-tooltip-shadow-1-offset-y, 2px)
var(--ctr-tooltip-shadow-1-blur, 6px) var(--ctr-tooltip-shadow-1-spread, 0px)
var(--ctr-tooltip-shadow-1-color, rgba(0, 0, 0, 0.1)),
var(--ctr-tooltip-shadow-2-offset-x, 0px) var(--ctr-tooltip-shadow-2-offset-y, 1px)
var(--ctr-tooltip-shadow-2-blur, 2px) var(--ctr-tooltip-shadow-2-spread, 0px)
var(--ctr-tooltip-shadow-2-color, transparent);
align-self: center;
position: absolute;
inset-inline-end: 100%;
Expand All @@ -124,7 +124,6 @@
clip-path: polygon(-100% -100%, -100% 200%, 200% 200%);
}


.sv-svg-icon use {
fill: var(--ctr-toolbox-item-icon-color-hovered, $primary);
}
Expand All @@ -151,11 +150,11 @@
// padding-inline-start: calcSize(4);
// }
}
.svc-toolbox__item-submenu-button {
background: var(--ctr-toolbox-item-submenu-button-background-color, $background-dim);
&:hover {
background: var(--ctr-toolbox-item-submenu-button-background-color-hovered, $background);
}
}
.svc-toolbox__item-submenu-button {
background: var(--ctr-toolbox-item-submenu-button-background-color, $background-dim);
&:hover {
background: var(--ctr-toolbox-item-submenu-button-background-color-hovered, $background);
}
}

Expand Down Expand Up @@ -218,7 +217,7 @@
.svc-toolbox__item-submenu-button {
position: absolute;
inset-inline-end: var(--ctr-toolbox-item-submenu-button-right, calcSize(1.5));
top: calcSize(1.5);
top: var(--ctr-toolbox-item-submenu-button-top, calcSize(1.5));
display: inline-flex;
padding: var(--ctr-toolbox-item-submenu-button-padding-top, 4px)
var(--ctr-toolbox-item-submenu-button-padding-right, 4px) var(--ctr-toolbox-item-submenu-button-padding-bottom, 4px)
Expand All @@ -228,7 +227,7 @@
box-sizing: border-box;
align-items: center;
border-radius: var(--ctr-toolbox-item-submenu-button-corner-radius, 1024px);
z-index: 20;
z-index: 40;
svg {
fill: var(--ctr-toolbox-item-submenu-button-icon-color, $layer-1-foreground-50);
}
Expand Down Expand Up @@ -276,8 +275,13 @@

.svc-toolbox-subtypes {
.sv-popup__container {
--toolbox-item-padding-top: calc(1 * #{$base-unit});
margin-top: calc(
0px - var(--ctr-toolbox-submenu-group-margin-top, 0px) -
var(--ctr-toolbox-item-padding-top, var(--toolbox-item-padding-top))
);
padding: 0;
padding-inline-start: var(--ctr-toolbox-submenu-offset, calcSize(0.5));
padding-inline-start: var(--ctr-toolbox-submenu-offset, calcSize(3.5));
box-shadow: unset;
background: unset;
}
Expand All @@ -301,10 +305,10 @@
}

.sv-popup__scrolling-content {
padding-top: calc(var(--ctr-toolbox-submenu-group-margin-top, 12px));
padding-inline-end: var(--ctr-toolbox-submenu-group-margin-right, 12px);
padding-bottom: var(--ctr-toolbox-submenu-group-margin-bottom-last, 12px);
padding-inline-start: var(--ctr-toolbox-submenu-group-margin-left, 12px);
padding-top: calc(var(--ctr-toolbox-submenu-group-margin-top, 0px));
padding-inline-end: var(--ctr-toolbox-submenu-group-margin-right, 0px);
padding-bottom: var(--ctr-toolbox-submenu-group-margin-bottom-last, 0px);
padding-inline-start: var(--ctr-toolbox-submenu-group-margin-left, 0px);
overflow: visible;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ export class ToolboxToolViewModel extends Base {
public onMouseOver(itemValue, mouseoverEvent) {
this.model.mouseOverHandler(itemValue);
}
public onMouseOverTool(itemValue, mouseoverEvent) {
if (itemValue.popupModel?.isVisible) this.onMouseOver(itemValue, mouseoverEvent);
}

public onMouseLeave(itemValue, mouseoverEvent) {
itemValue.hidePopupDelayed(this.creator.toolbox.subItemsHideDelay);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ svc-toolbox {
.svc-toolbox__search-container {
position: sticky;
top: 0;
z-index: 30;
display: none;
flex-direction: column;
box-sizing: border-box;
Expand Down
3 changes: 2 additions & 1 deletion packages/survey-creator-core/src/themes/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ const Theme = {
"--ctr-toolbox-scrollbar-right": "0",
"--ctr-toolbox-scroller-align-items": "flex-start",
"--ctr-toolbox-item-submenu-button-right": "8px",
"--ctr-toolbox-item-submenu-button-top": "12px",
"--ctr-toolbox-item-align": "stretch",
"--ctr-toolbox-submenu-offset": "13px",
"--ctr-toolbox-submenu-offset": "20px",
"--ctr-toolbox-width-compact": "72px",
"--ctr-toolbox-margin-left-compact": "0px",
"--ctr-toolbox-separator-width": "208px",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- ko component: { name: 'svc-toolbox-item', params: { model: $data.model, item: $data.item, creator: $data.creator, isCompact: $data.isCompact } } -->
<!-- /ko -->
<div class="svc-toolbox__item-submenu-button"
data-bind="event: { mouseover: onMouseOver }">
data-bind="event: { mouseover: onMouseOver, mouseleave: onMouseLeave }">
<!-- ko component: { name: 'sv-svg-icon', params: { iconName: item.subitemsButtonIcon, size: 16 } } --><!-- /ko -->
</div>
<sv-popup params="{ model: $data.item.popupModel, getArea: $data.item.getArea }"></sv-popup>
<sv-popup params="{ model: $data.item.popupModel, getArea: $data.item.getArea }"></sv-popup>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="svc-toolbox__category-separator"></div>
<!-- /ko -->
<div class="svc-toolbox__tool-content sv-action__content"
data-bind="event: { pointerdown: (model, event)=>{onPointerDown(event); return true;}, mouseover: function(model, event) { onMouseOverTool(model.item, event); return true; }, mouseleave: function(model, event) { onMouseLeave(model.item, event); return true; } }">
data-bind="event: { pointerdown: (model, event)=>{onPointerDown(event); return true;} }">
<!-- ko component: { name: $data.itemComponent, params: { model: $data, item: $data.item, creator: $data.creator, isCompact: $data.isCompact } } -->
<!-- /ko -->
</div>
Expand Down
6 changes: 0 additions & 6 deletions packages/survey-creator-react/src/toolbox/ToolboxItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ export class SurveyCreatorToolboxTool extends CreatorModelElement<
event.persist();
this.model.onPointerDown(event);
}}
onMouseOver={(event: any) => {
this.model.onMouseOverTool(item, event);
}}
onMouseLeave={(event: any) => {
this.model.onMouseLeave(item, event);
}}
>
{itemComponent}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export class SurveyCreatorToolboxItemGroup extends CreatorModelElement<ISurveyCr
onMouseLeave={(event: any) => this.model.onMouseLeave(this.item, event)}
>
<SvgIcon size={24} iconName={this.item.subitemsButtonIcon} ></SvgIcon>
<Popup model={this.item.popupModel} getArea={this.item.getArea} />
</div>
<Popup model={this.item.popupModel} getArea={this.item.getArea} />
</>;
}
}
Expand Down
15 changes: 9 additions & 6 deletions packages/survey-creator-vue/src/toolbox/ToolboxItemGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
:creator="creator"
:isCompact="isCompact"
></SvComponent>
<div class="svc-toolbox__item-submenu-button" @mouseover="hover">
<div class="svc-toolbox__item-submenu-button" @mouseover="hover" @mouseleave="leave">
<SvComponent :is="'sv-svg-icon'" :iconName="item.subitemsButtonIcon" :size="item.iconSize"></SvComponent>
<SvComponent
:is="'sv-popup'"
:model="item.popupModel"
:getArea="item.getArea"
></SvComponent>
</div>
<SvComponent
:is="'sv-popup'"
:model="item.popupModel"
:getArea="item.getArea"
></SvComponent>
</template>
<script lang="ts" setup>
import { SvComponent } from "survey-vue3-ui";
Expand All @@ -32,4 +32,7 @@ const props = defineProps<{
const hover = (event: MouseEvent) => {
props.viewModel.onMouseOver(props.item as QuestionToolboxItem, event);
};
const leave = (event: MouseEvent) => {
props.viewModel.onMouseLeave(props.item as QuestionToolboxItem, event);
};
</script>
10 changes: 0 additions & 10 deletions packages/survey-creator-vue/src/toolbox/ToolboxTool.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@
<div
class="svc-toolbox__tool-content sv-action__content"
@pointerdown="model?.onPointerDown"
@mousemove="
(e) => {
model?.onMouseOverTool(item, e);
}
"
@mouseleave="
(e) => {
model?.onMouseLeave(item, e);
}
"
>
<SvComponent
:viewModel="model"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified visualRegressionTests/tests/designer/etalons/page-content.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 d40411b

Please sign in to comment.