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

Search ability in mobile, display no results found, no right chevron in mobile #248

Merged
merged 13 commits into from
Jun 25, 2020

Conversation

caylahamann
Copy link
Contributor

@caylahamann caylahamann commented Jun 25, 2020

Description

Addresses various bug fixes for search in sidenav/mobile.

  • Search functionality in the mobile nav bar
  • Displays "No results found." when there are no matches in sidenav
  • Removes the right chevron in mobile view

Reviewer Notes

Reduce screen size to see mobile view, will see search bar there. Can type in random keys to get a no match for "no results found." Select a random page and reduce screen size to see the bolded page and the right chevron removed.

Related Issue(s) / Ticket(s)

  • DEVEX-1091 Missing search ability in mobile menu
  • DEVEX-1088 No messaging when there are no search results in navbar
  • DEVEX-1087 Right chevron next to current item in nav doesn't make sense on mobile

Screenshot(s)

Search functionality in mobile menu

Screen Shot 2020-06-25 at 11 27 17 AM

"No results found" messaging

Screen Shot 2020-06-25 at 11 26 49 AM

Removed right chevron

Screen Shot 2020-06-25 at 11 27 03 AM

@caylahamann
Copy link
Contributor Author

@djsauble would love your feedback on these since I mostly just guessed on what the design should look like!

@@ -123,7 +131,7 @@ const NavItem = ({ page, depthLevel, searchTerm, filteredPageNames }) => {
onKeyPress={() => setIsExpanded(!isExpanded)}
tabIndex={0}
>
{depthLevel > 0 && (
{!mobile && depthLevel > 0 && (
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than adding a new prop, passing it around, and doing these conditional checks, can we just target the chevron with CSS? We're already showing / hiding the mobile menu with a media query.

src/components/Navigation.js Outdated Show resolved Hide resolved
@zstix zstix added the enhancement New feature or request label Jun 25, 2020
@@ -35,6 +35,10 @@ const Navigation = ({ className, searchTerm }) => {
? filterPageNames(pages, searchTermSanitized)
: undefined;

if (filteredPageNames?.length === 0) {
Copy link
Contributor

@jerelmiller jerelmiller Jun 25, 2020

Choose a reason for hiding this comment

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

You may have a potential bug here. Is there ever a case where filteredPageNames is undefined or null? If so, comparing to 0 will result in false, thereby not showing the "No results found" message. If you can make sure filteredPageNames is always an empty array, then that should ensure this message is always shown at the appropriate time and would allow you to remove the ?..

Copy link
Contributor Author

@caylahamann caylahamann Jun 25, 2020

Choose a reason for hiding this comment

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

filteredPageNames will always return an array when you are searching, otherwise it will be undefined. When it is undefined, it will not have a property of length and then filteredPageNames?.length === 0 will evaluate to false! Otherwise, if it is being searched, then there will either be an array with values or an empty array. When it is an empty array, it will return "No results found." So I don't believe there is a bug possible.
Screen Shot 2020-06-25 at 1 06 16 PM

Copy link
Contributor

@djsauble djsauble left a comment

Choose a reason for hiding this comment

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

One minor suggestion but otherwise looks great!

@@ -35,6 +35,10 @@ const Navigation = ({ className, searchTerm }) => {
? filterPageNames(pages, searchTermSanitized)
: undefined;

if (filteredPageNames?.length === 0) {
return <div className={styles.emptyResults}>No results found</div>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest italicizing this just to emphasize that it's not a sidebar nav item

@zstix zstix merged commit e3223db into master Jun 25, 2020
@zstix zstix deleted the cayla/various-search-bugs branch June 25, 2020 22:59
@nr-opensource-bot
Copy link
Contributor

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants