Skip to content

Commit

Permalink
fix(NcActions): Use full window height
Browse files Browse the repository at this point in the history
Calculate the space on the window based on the trigger location.

Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux authored and backportbot[bot] committed Jul 16, 2024
1 parent 79ddba5 commit 5dcab73
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/components/NcActions/NcActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,6 @@ export default {
components: {
NcButton,
DotsHorizontal,
NcPopover,
},
Expand Down Expand Up @@ -1322,8 +1321,8 @@ export default {
this.focusIndex = 0
if (returnFocus) {
// Focus back the menu button
this.$refs.menuButton?.$el.focus()
// Focus back the trigger button
this.$refs.triggerButton?.$el.focus()
}
},
Expand All @@ -1338,23 +1337,23 @@ export default {
},
/**
* Hanle resizing the popover to make sure users can discover there is more to scroll
* Handle resizing the popover to make sure users can discover there is more to scroll
*/
resizePopover() {
// Get the inner v-popper element that defines the popover height (from floating-vue)
const inner = this.$refs.menu.closest('.v-popper__inner')
const maxHeight = Number.parseFloat(window.getComputedStyle(inner).maxHeight)
const height = this.$refs.menu.clientHeight
// If the popover height is limited by the max-height (scrollbars shown) limit the height to half of the last element
if (height > maxHeight) {
if (height > this.maxMenuHeight) {
// sum of action heights
let currentHeight = 0
// last action height
let actionHeight = 0
for (const action of this.$refs.menuList.children) {
// If the max height would be overflown by half of the current element,
// then we limit the height to the half of the previous element
if ((currentHeight + action.clientHeight / 2) > maxHeight) {
if ((currentHeight + action.clientHeight / 2) > this.maxMenuHeight) {
inner.style.height = `${currentHeight - actionHeight / 2}px`
break
}
Expand Down Expand Up @@ -1922,12 +1921,12 @@ export default {
// the popover__inner for actions only.
.v-popper--theme-dropdown.v-popper__popper.action-item__popper .v-popper__wrapper {
border-radius: var(--border-radius-large);
overflow:hidden;
overflow: hidden;
.v-popper__inner {
border-radius: var(--border-radius-large);
padding: 4px;
max-height: calc(50vh - 16px);
max-height: calc(100vh - var(--header-height));
overflow: auto;
}
}
Expand Down

0 comments on commit 5dcab73

Please sign in to comment.