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

Add KSelect dropdown to the Overlay layer #877

Merged

Conversation

AlexVelezLl
Copy link
Member

@AlexVelezLl AlexVelezLl commented Dec 20, 2024

Description

Finally, a robust solution is proposed to the many known issues with the KSelect dropdown by teleporting KSelect dropdown to the Overlay layer using Popper.

Issue addressed

Addresses #324 and #690.

Before/after screenshots

Before After
image image
image image
image image
If a modal had a long form, it bugged because of the overflowY: unset set because the Modal check for KSelects Now, we can have scrollables modals even if it has a KSelect inside
image Screenshot from 2024-12-26 16-01-41

Screencast showing the behaviour of KSelect in a long modal:

Compartir.pantalla.-.2024-12-26.16_10_21.mp4

Changelog

Steps to test

  1. Step 1
  2. Step 2
  3. ...

(optional) Implementation notes

At a high level, how did you implement this?

I have decided to close the dropdown on scroll, just like the KDropdownMenu, to avoid situations like this:

image

Otherwise we would need to be querying scrollable ancestors elements, and taking into account the height of any absolute/fixed elements like the topbar to automaticlly close the dropdown.

Does this introduce any tech-debt items?

Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical and brittle code paths are covered by unit tests
  • The change is described in the changelog section above

Reviewer guidance

  • Is the code clean and well-commented?
  • Are there tests for this change?
  • Are all UI components LTR and RTL compliant (if applicable)?
  • Add other things to check for here

Comments

Copy link
Member

@LianaHarris360 LianaHarris360 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for finding a solution to this problem! The code looks good and works correctly in most cases, except on the MyDownloads.vue page. The two dropdown menus aren't showing up, and there's an error message in the console related to the k-overlay element.

MydownloadsKSelects
Since there are only issues with these two, I'm not entirely sure if changes need to be made in Kolibri or KDS to fix it. I just wanted to mention it in case the problem can be solved in KDS, and if not, it might be considered a breaking change.

Just a quick note: since KModal no longer checks for KSelect, I believe we can remove the comment in lib/KSelect/index.vue that says, "BELOW: KModal targets KeenUiSelect by using div.ui-select selector" on line 11.


this.doClose();
},
100,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just out of curiosity, but how was the debounce time 100ms determined?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A 100ms delay is a common choice as it falls within the threshold of the shortest perceivable application response delay, as noted here. Although it will always depend on the context. If we were debouncing a user keyboard typing action, to lets say, trigger an api request after the user has finished typing we would rather use a >300 ms debounce delay depending on the context https://stackoverflow.com/questions/42361485/how-long-should-you-debounce-text-input.

@AlexVelezLl
Copy link
Member Author

Thanks @LianaHarris360! Yes, that was a problem because the KSelect's were being mounted before the DOMContentLoaded event was triggered and by that time, the KOverlay layer werent being mounted yet. This will be fixed when #879 is merged. Will ping Richard again since we had already agreed that this was the best solution :). I will then rebase this PR to have this fixed.

Just a quick note: since KModal no longer checks for KSelect, I believe we can remove the comment in lib/KSelect/index.vue that says, "BELOW: KModal targets KeenUiSelect by using div.ui-select selector" on line 11.

Thanks! Just removed it :)

@AlexVelezLl
Copy link
Member Author

I have just rebased the branch with the fix @LianaHarris360! Could you take another look? :)

@LianaHarris360 LianaHarris360 self-requested a review January 21, 2025 21:53
Copy link
Member

@LianaHarris360 LianaHarris360 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes are working as they should and the code logic makes sense, thanks for your work on this! @AlexVelezLl

@LianaHarris360 LianaHarris360 merged commit f4095e6 into learningequality:develop Jan 21, 2025
9 checks passed
learning-equality-bot bot pushed a commit that referenced this pull request Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants