Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate KSelect’s dropdown being displayed above the input in some cases even when there is enough space below #690

Open
MisRob opened this issue Jul 26, 2024 · 0 comments
Labels
Component: KSelect help wanted Open source contributors welcome P2 - normal Priority: Nice to have

Comments

@MisRob
Copy link
Member

MisRob commented Jul 26, 2024

🌱 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:

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: KSelect help wanted Open source contributors welcome P2 - normal Priority: Nice to have
Projects
None yet
Development

No branches or pull requests

1 participant