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

refactor navbar to be menubar #3300

Merged
merged 6 commits into from
Jan 24, 2024
Merged

refactor navbar to be menubar #3300

merged 6 commits into from
Jan 24, 2024

Conversation

johrstrom
Copy link
Contributor

This refactors the navigation bar to follow the menubar pattern. I'll try to leave comments here and there for more description on the changes.

The example/documentation I'm following is here:
https://www.w3.org/WAI/ARIA/apg/patterns/menubar/examples/menubar-navigation/

@abujeda can you please take a look at how this affects customizing the navigation bar? There could be some areas I missed and/or adversely affected.

def nav_link(title, icon, url, new_tab: false, role: nil, data: nil)
def nav_link(title, icon, url, new_tab: false, data: nil)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

all nav links have the same role, so i'm removing this bit (nobody is using it anyhow).

Comment on lines +10 to +13
<a title="<%= t('dashboard.nav_all_apps') %>" class="nav-link"
role="menuitem" href="<%= apps_index_path %>"
<%= aria %>
>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just feel like this is nicer than calling tag.a methods in partials. Aside from the actual addition of title and role, this is largely a cosmetic change to actually template out an anchor instead of programatically generating it.

Comment on lines -20 to +21
class: "#{local_assigns.fetch(:class, 'nav-link')} #{local_assigns.fetch(:role, nil)}",
class: "#{local_assigns.fetch(:class, 'nav-link')}",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The role was being added to the class for some reason? In any case, all these have the same role, so this is being removed from the nav_link api anyhow.

@abujeda
Copy link
Contributor

abujeda commented Jan 17, 2024

Will take a look and do some local testing

@johrstrom
Copy link
Contributor Author

Will take a look and do some local testing

Thanks, I'm working on fixing the tests now (because this breaks the structure)

@johrstrom
Copy link
Contributor Author

There is absolutely some wonkiness if you supply a custom help_menu with the default nav_bar.

<li class="nav-item dropdown" title="<%= group.title %>">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<li class="nav-item dropdown" role="none">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" role="menuitem">
Copy link
Contributor

@abujeda abujeda Jan 18, 2024

Choose a reason for hiding this comment

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

Should the a tag have the title attribute?

In local testing, there is no text appearing on hover over the menu title

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess it could. screen-reader reads it the same either way. The ul under this has a title, but I see what you mean - there's no hover over.

I wonder what the value is in a hover-over that has the same text you see on screen? In any case - I'm happy to add it back as it doesn't seem to affect accessibility.

@abujeda
Copy link
Contributor

abujeda commented Jan 18, 2024

There is absolutely some wonkiness if you supply a custom help_menu with the default nav_bar.

Not sure what the issue is. For me, with a custom help_bar and a custom help_menu looks ok.
If you show me what help_menu config you are using, I should be able to replicate.

Screenshot 2024-01-18 at 10 01 27 Screenshot 2024-01-18 at 10 01 48

@johrstrom
Copy link
Contributor Author

Looks like it could be on resize - I opened my dev tools and it resizes incorrectly. Note the whitespace to the right. The config is below - something from a test case but I think really it's the resize that does it.

image

```yaml help_bar: - title: Help Menu links: - group: 'Help Menu Dropdown Header' - title: 'Menu Link' url: /menu/link' new_tab: false - title: Profile Link profile: profile1 - title: Docs Menu links: - group: 'Docs Menu Dropdown Header' apps: - sys/bc_osc_jupyter - title: Custom Help Link url: '/custom/link' icon: 'fa://desktop' - user - logout ```

@johrstrom
Copy link
Contributor Author

Well, this may actually be off in the mainline. this is what it looks like in the mainline.

I think that's just how it's been rendering when there's no margin available between the nav_bar and the help_bar.
image

</ul>
</div>

<div class="ml-auto d-flex">
Copy link
Contributor

Choose a reason for hiding this comment

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

Regarding the navigation look and feel, If we change from:
<div class="ml-auto d-flex">
to
<div class="ml-auto navbar-collapse">

will vertically center the navigation items for the help bar, making the look and feel more consistent when there is no space

Copy link
Contributor

@abujeda abujeda Jan 18, 2024

Choose a reason for hiding this comment

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

nevermind, the helpbar is left aligned with the navbar-collpase class. Looking into alternatives

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This div is definitely the cause of the issues or at least the biggest cause.

There may be a way to figure out which element is where and apply an ml-auto (or mr-auto) to the appropriate element dynamically somewhere.

Copy link
Contributor

Choose a reason for hiding this comment

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

This seem to do the trick:
<div class="ml-auto d-flex align-items-center">

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea I can add align-items-center to the outter most ul - I think what I really need is an invisible div that adds the space between the nav_bar and help_menu instead of wrapping the help_menu inside a div. That'll likely help me fix the tests too when they all share the same general structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

May have fixed it, it seems like I tried this before, but it didn't work for whatever reason then...

In any case, just adding this div between the two seems to do the trick (instead of wrapping the help_menu in a parent div)
<div class="ml-auto"></div>

Copy link
Contributor

Choose a reason for hiding this comment

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

Changes look good locally 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the help!

<% else %>
<a class="navbar-brand" href="<%= root_path %>"><%= @user_configuration.dashboard_title %></a>
<% end %>
<ul class="navbar-nav w-100" role="menubar">
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the helpbar, to vertically center the logo:
<ul class="navbar-nav w-100 align-items-center" role="menubar">

@abujeda
Copy link
Contributor

abujeda commented Jan 18, 2024

If you want, once you are happy with the changes, I can fix the tests.
I know that you are pushing to complete other issues for 3.1

@johrstrom
Copy link
Contributor Author

If you want, once you are happy with the changes, I can fix the tests.
I know that you are pushing to complete other issues for 3.1

That would be fantastic! thank you so much! Yes I think I'm happy with the structure now. It's pretty uniform and appears to be OK.

That said - I'm not 100% sure the custom stuff renders exactly right, so there may be additional patches on that front.

@abujeda
Copy link
Contributor

abujeda commented Jan 18, 2024

OK - will start working on fixing the tests

@johrstrom johrstrom merged commit 55bf3f0 into master Jan 24, 2024
20 checks passed
@johrstrom johrstrom deleted the accessible-navbar branch January 24, 2024 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants