-
Notifications
You must be signed in to change notification settings - Fork 101
Description
🌱 Are you new to the codebase? Welcome! Please see the contributing guidelines.
Summary
When there is enough space, KSelect
's dropdown should be displayed below the input. However, there are several places in Kolibri where the dropdown is displayed above the input, even though there's enough space below. One example from Kolibri 0.17.0a0.dev0+git.123.g5cd1f6aa:
Coach → Plan → Lessons

This issue is present in other selects in Plan and Reports.
Interestingly, in a very similar place in Facility → Users, it works as expected:

The main culprit seems to be the bottom
positioning set to 62px
on .ui-select-dropdown
. After commenting it out, the dropdown shows correctly in the Coach:

The bottom
value is calculated in the calculateSpaceBelow
method:
kolibri-design-system/lib/KSelect/index.vue
Lines 878 to 893 in 0cbdf57
calculateSpaceBelow() { | |
// Get the height of element | |
const buttonHeight = this.$el.getBoundingClientRect().height; | |
// Get the position of the element relative to the viewport | |
const buttonPosition = this.$el.getBoundingClientRect().top; | |
// Check if there is enough space below element | |
// and update the "dropdownButtonBottom" data property accordingly | |
const notEnoughSpaceBelow = | |
buttonPosition > this.maxDropdownHeight && | |
this.scrollableAncestor.offsetHeight - buttonPosition < | |
buttonHeight + this.maxDropdownHeight; | |
this.dropdownButtonBottom = notEnoughSpaceBelow ? buttonHeight + 'px' : 'auto'; | |
}, |
The goal of this issue is to find out why exactly the calculation doesn't work well for places in the Coach (or check whether it’s overwritten from somewhere else, even though that’s rather unlikely). After we know more, we can determine the next steps and see if the calculation can be optimized.
References
Originally reported in learningequality/kolibri#12079 (not related to the refactor being tested there - the bug was present before).