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 search sizing on mobile (explore navbar overflow) #1760

Merged
merged 9 commits into from
Feb 28, 2022

Conversation

kaixin-hc
Copy link
Contributor

@kaixin-hc kaixin-hc commented Feb 12, 2022

What is the purpose of this pull request?
Fixes #1429

Also related: #1699

  • Documentation update
  • Bug fix
  • Feature addition or enhancement
  • Code maintenance
  • Others, please explain:

Overview of changes:

  • Set a minimum width for the scrollbar to be 8em. I tested this on the different device sizes of chrome and I think it looks fine on all; should guarantee at least least the whole placeholder attribute 'search' to be visible on the smallest screen sizes.
  • Make the section with items in the navigation bar scrollable in the case of overflow

search_scroll
Screenshot 2022-02-12 at 5 52 51 PM

Anything you'd like to highlight / discuss:

  • @jonahtanjz since this modifies your previous changes for mobile, I'd like your opinion!
  • Hiding the scrollbar in the navigation bar looks nice, but I'm not sure if it's very accessible.
  • Used em instead of vw for accessibility reasons(as it scales if the user zooms the screen)

Testing instructions:
Add lots of elements to the navigation bar to see it scroll + use google chrome mobile.

Proposed commit message: (wrap lines at 72 characters)
Make navbar scrollable & optimise search input size


Checklist: ☑️

  • Updated the documentation for feature additions and enhancements
  • Added tests for bug fixes or features
  • Linked all related issues
  • No unrelated changes

Copy link
Contributor

@tlylt tlylt left a comment

Choose a reason for hiding this comment

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

Hiding the scrollbar in the navigation bar looks nice, but I'm not sure if it's very accessible.

I agree with you that it looks nice without the scrollbar but I feel that indeed there might be valid concerns about accessibility.

In an extreme case where the navbar has quite a few items and some of them are nicely hidden behind the search box, it might be frustrating for site visitors who then become unaware & unable to find the target nav item.
image

I think perhaps one way is to explore creating custom css scrollbar which may be more visually appealing.
Or, perhaps we can consider something like what the Github extension that I am using is doing?
image

@kaixin-hc
Copy link
Contributor Author

What github extension are you using? I think putting a dropdown for excess navbar elements might be a better solution than a custom scrollbar.

For reference for what it looks like with a scrollbar:
w_scroll

Honestly, I don't think it's too bad either, but it's also one of those things that doesn't trigger unless you actually try to scroll on the screen (and I'm not sure if it would work with windows computers, since I scroll using an apple mouse and I'm not sure if the scroll bar would activate on windows since it only shows up when I try to scroll). So it wouldn't help people who didn't know the navbar was intended to be scrollable.

@tlylt
Copy link
Contributor

tlylt commented Feb 12, 2022

What github extension are you using?

https://github.com/refined-github/refined-github

@jonahtanjz
Copy link
Contributor

jonahtanjz commented Feb 13, 2022

Hiding the scrollbar in the navigation bar looks nice, but I'm not sure if it's very accessible.

The issue with using the native scrollbar is that it can differ depending on OS and browser. For example this is how it looks on windows 10 Chrome

image

In this case I would agree with @tlylt to create a custom scrollbar for desktop to keep the design consistent.

Or, perhaps we can consider something like what the Github extension that I am using is doing?

I think putting a dropdown for excess navbar elements might be a better solution than a custom scrollbar.

I think this is a good idea. We can follow how Github is doing it 👍

image

@ong6
Copy link
Contributor

ong6 commented Feb 13, 2022

Just throwing my opinion out here, but I think a native scrollbar is not the best solution, a dropdown like @tlylt and @jonahtanjz
suggested is better. Especially when users want to see all the options in the navbar.

@kaixin-hc
Copy link
Contributor Author

Hmm, I'm also leaning towards the dropdown (which isn't how github does it but an extension) as opposed to the custom scrollbar. Considering this, I'll edit the description to just fixing the iPad issue? To keep changes separate, would it be possible to merge this first to fix the bug and then I make a separate PR for the dropdown?

@ong6
Copy link
Contributor

ong6 commented Feb 13, 2022

Hmm, I'm also leaning towards the dropdown (which isn't how github does it but an extension) as opposed to the custom scrollbar. Considering this, I'll edit the description to just fixing the iPad issue? To keep changes separate, would it be possible to merge this first to fix the bug and then I make a separate PR for the dropdown?

Yep, that sounds good.

Copy link
Contributor

@jonahtanjz jonahtanjz left a comment

Choose a reason for hiding this comment

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

I'll edit the description to just fixing the iPad issue? To keep changes separate, would it be possible to merge this first to fix the bug and then I make a separate PR for the dropdown?

Alright sure. Just one suggestion for the implementation of the searchbar.

Comment on lines +252 to +256
<style scoped>
.form-control {
min-width: 8em;
}
</style>
Copy link
Contributor

@jonahtanjz jonahtanjz Feb 13, 2022

Choose a reason for hiding this comment

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

Can shift the rest of the css rules below to this scoped style as well

@kaixin-hc
Copy link
Contributor Author

kaixin-hc commented Feb 13, 2022

I'm not sure if we should move the CSS rules into the scoped style, due to this note on the vue documentation:

Scoped styles do not eliminate the need for classes. Due to the way browsers render various CSS selectors, p { color: red } will be many times slower when scoped (i.e. when combined with an attribute selector). If you use classes or ids instead, such as in .example { color: red }, then you virtually eliminate that performance hit.

Any thoughts?

@jonahtanjz
Copy link
Contributor

Any thoughts?

#1768

Copy link
Contributor

@jonahtanjz jonahtanjz left a comment

Choose a reason for hiding this comment

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

@kaixin-hc, I think we can merge this first while waiting for the discussion on scoped styles.

One last thing, I noticed that by using overflow-x: scroll on the default navbar, it causes the dropdown to break.

Landing.Page.-.Google.Chrome.2022-02-15.17-18-12.mp4

It may take quite a bit of work to resolve this. Since we are intending to remove scroll for ipad/desktop and use dropdown for overflow, there is not much value in resolving this. We can limit this PR to just the searchbar and remove the changes made for the scrolling :)

@kaixin-hc
Copy link
Contributor Author

kaixin-hc commented Feb 23, 2022

Sorry for the delay @jonahtanjz ! I've reverted the changes.

I was curious about the scrollbar issue, so I did a little digging for my own learning. After a few stack overflow posts and reading, I found this article: https://css-tricks.com/popping-hidden-overflow/ that explains that setting overflow-x sets overflow-y as well, and it's just not possible to have a dropdown peep out of a scrollable overflow without setting positions relatively. This discussion with the offered solution was also interesting. Not sure how to implement it cleanly in a vue component, but it is a non-issue.

I think it also shows the need for #1714

@tlylt
Copy link
Contributor

tlylt commented Feb 23, 2022

@all-contributors please add @kaixin-hc for code

@allcontributors
Copy link
Contributor

@tlylt

I've put up a pull request to add @kaixin-hc! 🎉

@@ -306,7 +306,6 @@ export default {
.navbar-default {
display: block;
margin-top: 0.3125rem;
width: 100%;
Copy link
Contributor

@jonahtanjz jonahtanjz Feb 24, 2022

Choose a reason for hiding this comment

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

@kaixin-hc I believe this is still needed so that the default-navbar will always go to the next line on mobile :)

Tried with 2 items in the default-navbar with window width of 700px:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2022-02-28 at 1 21 48 PM

Good catch! Though I've enclosed a picture for further reference, as I think that it looks quite strange with just two items. After some consideration I think it's still alright, since I expect this would be an edge case and it doesn't seem to have any usability issues. An alternative work around might be triggering the "go to next line" when the screen size is smaller or when the nav-bar default has a certain number of items, but I think that's more trouble than it's worth

@jonahtanjz jonahtanjz added this to the 4.0 milestone Feb 28, 2022
@jonahtanjz jonahtanjz merged commit 0e775d5 into MarkBind:master Feb 28, 2022
@kaixin-hc kaixin-hc changed the title Fix navbar overflow on mobile Fix search sizing on mobile (explore navbar overflow) Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Small search bar and cropped dropdown menu on iPad
4 participants