Skip to content

Commit

Permalink
fix: calculate select2 results max-height correctly when they are ope…
Browse files Browse the repository at this point in the history
…ned as "dropup"
  • Loading branch information
petschki committed Feb 26, 2024
1 parent 9e6f366 commit 4dfebfe
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/pat/relateditems/relateditems.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,11 +687,12 @@ export default Base.extend({
this.renderToolbar();
this.$el.on("select2-loaded", () => {
let yMax = window.innerHeight || document.documentElement.clientHeight;
const relitem_rect = this.el.parentElement.getBoundingClientRect();
const element = $(
".pat-relateditems-dropdown.select2-drop-active .select2-results"
)[0];
const rect = element.getBoundingClientRect();
const maxHeight = yMax - rect.top - 18;
const maxHeight = ((relitem_rect.top > rect.top) ? relitem_rect.top : yMax - rect.top) - 18;
$(element).css("max-height", `${maxHeight}px`);
});

Expand Down

0 comments on commit 4dfebfe

Please sign in to comment.