Skip to content

Commit

Permalink
fix #2508 MultiSelect Dropdown out of screen bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
13twelve committed Dec 10, 2024
1 parent 90da826 commit a958441
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 2 deletions.
48 changes: 46 additions & 2 deletions frontend/js/components/VSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
:requiredValue="required"
:maxHeight="maxHeight"
:disabled="disabled"
:calculate-position="withPopper"
append-to-body
@input="updateValue"
@search="getOptions"
>
Expand All @@ -37,8 +39,22 @@
</div>
</template>

<style>
.vs__dropdown-menu {
transition: none;
}
.vs__dropdown-menu[data-popper-placement='top'] {
border-radius: 4px 4px 0 0;
border-top-style: solid;
border-bottom-style: none;
box-shadow: 0 -3px 6px rgba(0, 0, 0, 0.15);
}
</style>

<script>
import debounce from 'lodash/debounce'
import { createPopper } from '@popperjs/core'
// check full options of the vueSelect here : http://sagalbot.github.io/vue-select/
import extendedVSelect from '@/components/VSelect/ExtendedVSelect.vue'
Expand Down Expand Up @@ -135,7 +151,8 @@
return {
value: this.selected,
currentOptions: this.options,
ajaxUrl: this.endpoint
ajaxUrl: this.endpoint,
placement: 'bottom',
}
},
watch: {
Expand Down Expand Up @@ -254,7 +271,34 @@
// error callback
loading(false)
})
}, 500)
}, 500),
withPopper(dropdownList, component, { width }) {
// position top/bottom taken from https://vue-select.org/guide/positioning.html#popper-js-integration
dropdownList.style.width = width
const popper = createPopper(component.$refs.toggle, dropdownList, {
placement: this.placement,
modifiers: [
{
name: 'offset',
options: {
offset: [0, -1],
},
},
{
name: 'toggleClass',
enabled: true,
phase: 'write',
fn({ state }) {
component.$el.classList.toggle(
'drop-up',
state.placement === 'top'
)
},
},
],
})
return () => popper.destroy()
},
}
}
</script>
58 changes: 58 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"dependencies": {
"@alpinejs/mask": "^3.13.5",
"@floating-ui/vue": "^1.1.5",
"@tiptap/extension-hard-break": "^2.2.1",
"@tiptap/extension-horizontal-rule": "^2.2.1",
"@tiptap/extension-link": "^2.2.1",
Expand Down

0 comments on commit a958441

Please sign in to comment.