fix: Avoid overflowing submenus in conversation context menu (#5113)

* Scroll overflowing content inside submenus

* Disable submenus if options are not available
This commit is contained in:
Fayaz Ahmed 2022-10-20 00:53:53 +05:30 committed by GitHub
parent 2e7ab484bd
commit 3de8f256cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 7 deletions

View file

@ -17,7 +17,10 @@
@click="snoozeConversation(option.snoozedUntil)" @click="snoozeConversation(option.snoozedUntil)"
/> />
</menu-item-with-submenu> </menu-item-with-submenu>
<menu-item-with-submenu :option="labelMenuConfig"> <menu-item-with-submenu
:option="labelMenuConfig"
:sub-menu-available="!!labels.length"
>
<template> <template>
<menu-item <menu-item
v-for="label in labels" v-for="label in labels"
@ -28,7 +31,10 @@
/> />
</template> </template>
</menu-item-with-submenu> </menu-item-with-submenu>
<menu-item-with-submenu :option="agentMenuConfig"> <menu-item-with-submenu
:option="agentMenuConfig"
:sub-menu-available="!!assignableAgents.length"
>
<agent-loading-placeholder v-if="assignableAgentsUiFlags.isFetching" /> <agent-loading-placeholder v-if="assignableAgentsUiFlags.isFetching" />
<template v-else> <template v-else>
<menu-item <menu-item
@ -40,7 +46,10 @@
/> />
</template> </template>
</menu-item-with-submenu> </menu-item-with-submenu>
<menu-item-with-submenu :option="teamMenuConfig"> <menu-item-with-submenu
:option="teamMenuConfig"
:sub-menu-available="!!teams.length"
>
<menu-item <menu-item
v-for="team in teams" v-for="team in teams"
:key="team.id" :key="team.id"

View file

@ -18,7 +18,7 @@
size="20px" size="20px"
class="agent-thumbnail" class="agent-thumbnail"
/> />
<p class="menu-label truncate-text">{{ option.label }}</p> <p class="menu-label text-truncate">{{ option.label }}</p>
</div> </div>
</template> </template>
@ -50,7 +50,6 @@ export default {
padding: var(--space-smaller); padding: var(--space-smaller);
border-radius: var(--border-radius-small); border-radius: var(--border-radius-small);
overflow: hidden; overflow: hidden;
.menu-label { .menu-label {
margin: 0; margin: 0;
font-size: var(--font-size-mini); font-size: var(--font-size-mini);

View file

@ -1,11 +1,14 @@
<template> <template>
<div class="menu-with-submenu flex-between"> <div
class="menu-with-submenu flex-between"
:class="{ disabled: !subMenuAvailable }"
>
<div class="menu-left"> <div class="menu-left">
<fluent-icon :icon="option.icon" size="14" class="menu-icon" /> <fluent-icon :icon="option.icon" size="14" class="menu-icon" />
<p class="menu-label">{{ option.label }}</p> <p class="menu-label">{{ option.label }}</p>
</div> </div>
<fluent-icon icon="chevron-right" size="12" /> <fluent-icon icon="chevron-right" size="12" />
<div class="submenu"> <div v-if="subMenuAvailable" class="submenu">
<slot /> <slot />
</div> </div>
</div> </div>
@ -18,6 +21,10 @@ export default {
type: Object, type: Object,
default: () => {}, default: () => {},
}, },
subMenuAvailable: {
type: Boolean,
default: true,
},
}, },
}; };
</script> </script>
@ -55,6 +62,11 @@ export default {
left: 100%; left: 100%;
top: 0; top: 0;
display: none; display: none;
min-height: min-content;
max-height: var(--space-giga);
overflow-y: auto;
// Need this because Firefox adds a horizontal scrollbar, if a text is truncated inside.
overflow-x: hidden;
} }
&:hover { &:hover {
@ -73,5 +85,10 @@ export default {
clip-path: polygon(100% 0, 0% 0%, 100% 100%); clip-path: polygon(100% 0, 0% 0%, 100% 100%);
} }
} }
&.disabled {
opacity: 50%;
cursor: not-allowed;
}
} }
</style> </style>