Skip to content

Commit 29ca775

Browse files
committed
fix: actions menu for envelope
Signed-off-by: Roberto Guido <info@madbob.org>
1 parent fbe86ff commit 29ca775

2 files changed

Lines changed: 33 additions & 83 deletions

File tree

src/components/EnvelopeSingleClickActions.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,9 @@ export default {
7777
</script>
7878

7979
<style lang="scss" scoped>
80+
8081
.list-item-content__quick-actions {
81-
display: none;
82+
display: flex;
8283
}
8384
84-
.list-item:hover {
85-
.list-item-content__quick-actions {
86-
display: flex;
87-
}
88-
}
8985
</style>

src/components/EnvelopeSkeleton.vue

Lines changed: 31 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@
3131
:href="routerLinkHref || href"
3232
:target="target || (href === '#' ? undefined : '_blank')"
3333
:rel="href === '#' ? undefined : 'noopener noreferrer'"
34-
@focus="showActions"
34+
@focus="handleMouseover"
3535
@focusout="handleBlur"
3636
@click="onClick($event, navigate, routerLinkHref)"
37-
@contextmenu.prevent
38-
@keydown.esc="hideActions">
37+
@contextmenu.prevent>
3938
<!-- @slot This slot is used for the NcAvatar or icon, the content of this slot must not be interactive -->
4039
<slot name="icon" />
4140

@@ -93,7 +92,7 @@
9392
</div>
9493
</a>
9594

96-
<div class="list-item__hoverable">
95+
<div class="list-item__hoverable" v-show="displayActionsOverlay">
9796
<EnvelopeSingleClickActions
9897
:is-read="isRead"
9998
:is-important="isImportant"
@@ -103,7 +102,7 @@
103102

104103
<!-- Actions -->
105104
<div
106-
v-show="forceDisplayActions || displayActionsOnHoverFocus"
105+
v-show="hasActions"
107106
class="list-item__actions"
108107
@focusout="handleBlur">
109108
<NcActions
@@ -256,14 +255,6 @@ export default {
256255
},
257256
},
258257
259-
/**
260-
* To be used only when the elements in the actions menu are very important
261-
*/
262-
forceDisplayActions: {
263-
type: Boolean,
264-
default: false,
265-
},
266-
267258
/**
268259
* Show the list component layout
269260
*/
@@ -293,7 +284,6 @@ export default {
293284
hovered: false,
294285
hasActions: false,
295286
hasSubname: false,
296-
displayActionsOnHoverFocus: false,
297287
menuOpen: false,
298288
hasIndicator: false,
299289
hasDetails: false,
@@ -302,26 +292,20 @@ export default {
302292
303293
computed: {
304294
showAdditionalElements() {
305-
return !this.displayActionsOnHoverFocus || this.forceDisplayActions
295+
return !this.hasActions
306296
},
307297
308298
showDetails() {
309299
return (this.details !== '' || this.hasDetails)
310-
&& (!this.displayActionsOnHoverFocus || this.forceDisplayActions)
300+
&& !this.hasActions
311301
},
312302
313303
computedActionsAriaLabel() {
314304
return this.actionsAriaLabel || t('Actions for item with name "{name}"', { name: this.name })
315305
},
316-
},
317-
318-
watch: {
319306
320-
menuOpen(newValue) {
321-
// A click outside both the menu and the root element hides the actions again
322-
if (!newValue && !this.hovered) {
323-
this.displayActionsOnHoverFocus = false
324-
}
307+
displayActionsOverlay() {
308+
return this.menuOpen || this.hovered
325309
},
326310
},
327311
@@ -355,50 +339,31 @@ export default {
355339
}
356340
},
357341
358-
showActions() {
359-
if (this.hasActions) {
360-
this.displayActionsOnHoverFocus = true
361-
}
342+
/**
343+
* Hide the actions on mouseleave unless the menu is open
344+
*/
345+
handleMouseleave() {
362346
this.hovered = false
363347
},
364348
365-
hideActions() {
366-
this.displayActionsOnHoverFocus = false
349+
handleMouseover() {
350+
this.hovered = true
367351
},
368352
369-
/**
370-
* @param {FocusEvent} event UI event
371-
*/
372-
handleBlur(event) {
373-
// do not hide if open
374-
if (this.menuOpen) {
375-
return
376-
}
353+
handleBlur(e) {
377354
// do not hide if focus is kept within
378-
if (this.$refs['list-item'].contains(event.relatedTarget)) {
355+
if (this.$refs['list-item'].contains(e.relatedTarget)) {
379356
return
380357
}
381-
this.hideActions()
382-
},
383358
384-
/**
385-
* Hide the actions on mouseleave unless the menu is open
386-
*/
387-
handleMouseleave() {
388-
if (!this.menuOpen) {
389-
this.displayActionsOnHoverFocus = false
390-
}
391359
this.hovered = false
392360
},
393361
394-
handleMouseover() {
395-
this.showActions()
396-
this.hovered = true
397-
},
398-
399362
handleActionsUpdateOpen(e) {
400-
this.menuOpen = e
401-
this.$emit('update:menuOpen', e)
363+
setTimeout(() => {
364+
this.menuOpen = e
365+
this.$emit('update:menuOpen', e)
366+
})
402367
},
403368
404369
// Check if subname and actions slots are populated
@@ -454,10 +419,6 @@ export default {
454419
.list-item-details__details {
455420
color: var(--color-primary-element-text);
456421
}
457-
458-
.list-item-content__quick-actions :deep(svg) {
459-
fill: var(--color-primary-element-text) !important;
460-
}
461422
}
462423
.list-item-content__name,
463424
.list-item-content__subname,
@@ -510,10 +471,6 @@ export default {
510471
box-shadow: 0 0 0 4px var(--color-main-background);
511472
}
512473
513-
&__hoverable {
514-
visibility: hidden;
515-
}
516-
517474
.list-item-content {
518475
display: flex;
519476
flex-direction: column;
@@ -702,20 +659,17 @@ export default {
702659
703660
}
704661
705-
.list-item:hover {
706-
.list-item__hoverable {
707-
visibility: visible;
708-
position: absolute;
709-
display: flex;
710-
background: var(--color-main-background);
711-
border-radius: var(--border-radius-element);
712-
box-shadow: 0 0 4px 0 var(--color-box-shadow);
713-
height: var(--default-clickable-area);
714-
inset-inline-end: var(--default-grid-baseline);
715-
716-
:deep(svg) {
717-
fill: var(--color-main-text) !important; // needed to not inherit active styling
718-
}
662+
.list-item__hoverable {
663+
position: absolute;
664+
display: flex;
665+
background: var(--color-main-background);
666+
border-radius: var(--border-radius-element);
667+
box-shadow: 0 0 4px 0 var(--color-box-shadow);
668+
height: var(--default-clickable-area);
669+
inset-inline-end: var(--default-grid-baseline);
670+
671+
:deep(svg) {
672+
fill: var(--color-main-text) !important; // needed to not inherit active styling
719673
}
720674
}
721675

0 commit comments

Comments
 (0)