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

Fix top navigation positioning when window is resized #13007

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

LianaHarris360
Copy link
Member

Summary

This pull request adjusts the positioning of the NavBar within AppBar.vue so that the tabs in the navigation move to the second line when the page shrinks and there isn't enough space. Only after that, on smaller screen sizes, is the overflow menu dropdown button displayed.

This issue is most apparent in the Coach plugin when the classroom title is very long, however this change does impact other Kolibri plugins.

To prevent the overflow menu dropdown button from appearing when the navigation is at the top position, the top NavBar is hidden and the bottom NavBar is displayed if the breakpointLimit is less than the windowBreakpoint during window resizing. Alternatively, if the breakpointLimit is greater than the windowBreakpoint, the top NavBar is shown and the bottom NavBar is hidden.

Based on the length of the title property, the breakpointLimit is either 4 or 3. For example, if the page title is longer than 20 characters, the top NavBar will be shown until the windowBreakpoint equals 4.

A window resize event listener has also been added to AppBarPage to update appBarHeight and improve page responsiveness when the screen size and NavBar position changes, replacing the use of windowBreakpoint within AppBarPage.

Before:

384394615-d324f647-e98b-4ed3-9397-85248fec9568.mp4

After:

WindowResizing.mov

References

Fixes #12813

Reviewer guidance

  1. Create a class with a long class name.
  2. Navigate to Coach > Class home and resize the page to see the responsive design behavior

…sition and implement a window resize event listener to update showTopNavBar based on the breakpoint
…improve responsiveness with screen size and NavBar position changes
@marcellamaki
Copy link
Member

@pcenov this seems relatively straightforward, but if it can go on your to-do list I would appreciate the QA team review! thank you (cc @radinamatic)

@@ -222,9 +224,18 @@
window.addEventListener('click', this.handleWindowClick);
window.addEventListener('keydown', this.handlePopoverByKeyboard, true);
Copy link
Member

@akolson akolson Jan 30, 2025

Choose a reason for hiding this comment

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

Probably out of scope for this fix, but might be worth using the opportunity to move the event additions to the mounted hook instead? Unless there are strong opinions one why it was done that way :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not against moving these event listeners to the mounted hook instead, I will update the PR with this change.

@@ -222,9 +224,18 @@
window.addEventListener('click', this.handleWindowClick);
window.addEventListener('keydown', this.handlePopoverByKeyboard, true);
},
beforeUpdate() {
// Essential for title updates after data finishes loading
this.breakpointLimit = this.title && this.title.length >= 20 ? 4 : 3;
Copy link
Member

Choose a reason for hiding this comment

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

Is the title length we are checking against arbitrary?

Copy link
Member Author

@LianaHarris360 LianaHarris360 Jan 30, 2025

Choose a reason for hiding this comment

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

This comparison to the title length is important for determining the lowest breakpointLimit, which is initially set to be 4. However, with a title length that is 20 characters or less, the NavBar can be positioned at the bottom when the windowBreakpoint is 3, without the overflow menu button being displayed. With longer titles, the breakpointLimit should continue to be 4.

Copy link
Member

@akolson akolson Jan 30, 2025

Choose a reason for hiding this comment

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

Ahh I see, thanks. For purposes of clarity, I think it would be great to add a comment( or use descriptive variable or both? whichever makes more sense) describing that the value 20 is what is currently specified as the maximum title length on small windows. Otherwise, this could end up being a potential source of bugs, considering that any change here would also require a change in the AppBar.js where this value is specified.

:text="windowIsSmall ? truncateText(title, 20) : truncateText(title, 50)"

Copy link
Member

@akolson akolson left a comment

Choose a reason for hiding this comment

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

Hi @LianaHarris360! Changes look good and make sense to me! The only question I have is around how we arrive to the title length we used to determine the breakpoint limit. Beyond that, we should be good to go after manual QA.

@LianaHarris360
Copy link
Member Author

@marcellamaki observed that switching the language to Fulfulde resulted in longer navigation link text in the Coach plugin, which triggered the overflow menu button even though the navbar was positioned at the top of the AppBar.

The navbar position is now determined by the widthThreshold variable: it is set to 1600 if the AppBar title is 20 characters or longer, and 1350 otherwise. This allows the navbar to dynamically adjust its position based on the available space in the AppBar.

navbarPosition.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants