Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fixing conflicting hover states between sticky button and node view. #3368

Merged
merged 3 commits into from
May 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 43 additions & 7 deletions packages/editor-ui/src/views/NodeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,20 @@
</div>
<NodeDetailsView :renaming="renamingActive" @valueChanged="valueChanged"/>
<div
class="node-buttons-wrapper"
:class="['node-buttons-wrapper', showStickyButton ? 'no-events' : '']"
v-if="!createNodeActive && !isReadOnly"
@mouseenter="onCreateMenuHoverIn"
>
<div class="node-creator-button">
<n8n-icon-button size="xlarge" icon="plus" @click="() => openNodeCreator('add_node_button')" :title="$locale.baseText('nodeView.addNode')"/>
<div class="add-sticky-button" @click="nodeTypeSelected(STICKY_NODE_TYPE)">
<n8n-icon-button
size="xlarge"
icon="plus"
@click="() => openNodeCreator('add_node_button')" :title="$locale.baseText('nodeView.addNode')"
/>
<div
:class="['add-sticky-button', showStickyButton ? 'visible-button' : '']"
@click="nodeTypeSelected(STICKY_NODE_TYPE)"
>
<n8n-icon-button size="large" :icon="['far', 'note-sticky']" type="outline" :title="$locale.baseText('nodeView.addSticky')"/>
</div>
</div>
Expand Down Expand Up @@ -385,6 +393,7 @@ export default mixins(
pullConnActive: false,
dropPrevented: false,
renamingActive: false,
showStickyButton: false,
};
},
beforeDestroy () {
Expand All @@ -395,6 +404,29 @@ export default mixins(
document.removeEventListener('keyup', this.keyUp);
},
methods: {
onCreateMenuHoverIn(mouseinEvent: MouseEvent) {
const buttonsWrapper = mouseinEvent.target as Element;

// Once the popup menu is hovered, it's pointer events are disabled so it's not interfering with element underneath it.
this.showStickyButton = true;
const moveCallback = (mousemoveEvent: MouseEvent) => {
if(buttonsWrapper) {
const wrapperBounds = buttonsWrapper.getBoundingClientRect();
const wrapperH = wrapperBounds.height;
const wrapperW = wrapperBounds.width;
const wrapperLeftNear = wrapperBounds.left;
const wrapperLeftFar = wrapperLeftNear + wrapperW;
const wrapperTopNear = wrapperBounds.top;
const wrapperTopFar = wrapperTopNear + wrapperH;
const inside = ((mousemoveEvent.pageX > wrapperLeftNear && mousemoveEvent.pageX < wrapperLeftFar) && (mousemoveEvent.pageY > wrapperTopNear && mousemoveEvent.pageY < wrapperTopFar));
if(!inside) {
this.showStickyButton = false;
document.removeEventListener('mousemove', moveCallback, false);
}
}
};
document.addEventListener('mousemove', moveCallback, false);
},
clearExecutionData () {
this.$store.commit('setWorkflowExecutionData', null);
this.updateNodesExecutionIssues();
Expand Down Expand Up @@ -2937,6 +2969,10 @@ export default mixins(
bottom: 10px;
}

.no-events {
pointer-events: none;
}

.node-buttons-wrapper {
position: fixed;
width: 150px;
Expand All @@ -2952,10 +2988,9 @@ export default mixins(
transition-timing-function: linear;
}

&:hover {
.add-sticky-button {
opacity: 1;
}
.visible-button {
opacity: 1;
pointer-events: all;
}
}

Expand All @@ -2964,6 +2999,7 @@ export default mixins(
text-align: center;
top: 80px;
right: 20px;
pointer-events: all !important;
}

.node-creator-button button {
Expand Down