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

Layered Navigation - Desktop Optimizations #3137

Conversation

justinconabree
Copy link
Contributor

Description

  • Display the layered navigation contents directly on the category and search pages when on desktop (equal to or above 1024px).
  • Changed the markup/layout of the category and search pages to support the left column on desktop.
  • Moved and styled the Sort button on desktop. It now also includes the current sorting within the button text.
  • Added X Results messaging above the results on category pages (both mobile and desktop)
  • Added Show More / Show Less button within the filter list when there are more than 5 items (both mobile and desktop). You can also pass in a new prop "showItems" to the FilterList change this threshold
  • Open the first 3 filter accordions on desktop. You can also pass in a new prop "filtersOpen" to the FilterSidebar change this threshold
  • Also open any filters that have selected items (both mobile and desktop)
  • Scroll to the top of filters (-150px for menu threshold) when changing the filters on desktop

Related Issue

Closes #3115

Acceptance

Verification Stakeholders

Specification

Verification Steps

  1. Go to the Bottoms category page on a desktop browser
  2. Verify the layered nav is visible on the left
  3. Verify the sort button is on the right and displays current sort order within button
  4. Verify the first 3 filters are open and the rest are closed
  5. Verify the Show More/Less works correctly within the Color attribute list
  6. Verify selecting a filter in one of the closed attributes (ex Size) then forces the accordion open (but can still be manually closed)
  7. Verify selecting a filter lower down on the page scrolls the viewport back to the top of the filter list
  8. Verify that the mobile filters reflect what was selected on desktop and function as they did before these modifications
  9. Search for "pants"
  10. Verify the layout is functioning as it did in the category page

Screenshots / Screen Captures (if appropriate)

image
image
image

Checklist

[ ] I have added tests to cover my changes, if necessary.
[x] I have updated existing tests to cover my changes, if necessary.
[x] I have added translations for new strings, if necessary.
[x] I have updated the documentation accordingly, if necessary.

…rch layout and styles for sidebar, keep filter accordion open if selected or in first 3 (magento#3115)
…nd add icon, implement show more/less in filter list, scroll to top on apply filter, add total number of results in toolbar, add filter header
… move productSort styles to productSort component (magento#3115)
@PWAStudioBot
Copy link
Contributor

PWAStudioBot commented Apr 21, 2021

Messages
📖 DangerCI Failures related to missing labels/description/linked issues/etc will persist until the next push or next nightly build run (assuming they are fixed).
📖

Access a deployed version of this PR here. Make sure to wait for the "pwa-pull-request-deploy" job to complete.

Generated by 🚫 dangerJS against 938c0eb

@fooman
Copy link
Contributor

fooman commented May 2, 2021

Not sure if this is a graphql issue or expected. On https://pr-3137.pwa-venia.com/shop-the-look.html?page=1 you start out with 10 Results
image

Clicking the first price filter cuts down the results to 2

image

Enabling the second filter I would anticipate seeing all products again. However it is still stuck at 2
image

@fooman
Copy link
Contributor

fooman commented May 6, 2021

Just to confirm selecting multiple price bands seems to be problematic prior to this PR - for example https://pr-3146.pwa-venia.com/shop-the-look.html?page=1&price%5Bfilter%5D=100-200%2C100_200&price%5Bfilter%5D=0-100%2C0_100

@sirugh
Copy link
Contributor

sirugh commented May 6, 2021

Just to confirm selecting multiple price bands seems to be problematic prior to this PR - for example https://pr-3146.pwa-venia.com/shop-the-look.html?page=1&price%5Bfilter%5D=100-200%2C100_200&price%5Bfilter%5D=0-100%2C0_100

Thanks @fooman, opened #3161

@sirugh sirugh added the version: Major This changeset includes incompatible API changes and its release necessitates a Major version bump. label May 11, 2021
Copy link
Contributor

@sirugh sirugh left a comment

Choose a reason for hiding this comment

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

This looks great! Thank you so much for your patience while we worked to get the accessibility PR merged. I've left some feedback for you! A large number of the comments are just me identifying a prop rename, but there are a few things in here I'd like to see addressed if possible.

Please let me know if you have time to address this review or if you need someone on the internal team to take it over from here.

packages/venia-ui/lib/RootComponents/Category/category.css Outdated Show resolved Hide resolved
@@ -1,5 +1,5 @@
.root {
--stroke: var(--venia-global-color-border);
--stroke: rgb(var(--venia-global-color-border));
Copy link
Contributor

Choose a reason for hiding this comment

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

Just an FYI, this might conflict with a fix incoming in #3171.

cc @tjwiebell

*/
const FilterSidebar = props => {
const { filters, filtersOpen } = props;
const talonProps = useFilterModal({ filters });
Copy link
Contributor

@sirugh sirugh May 11, 2021

Choose a reason for hiding this comment

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

We don't have this really documented anywhere, and we've recently run into this with the WishlistButton work, but the relationship between talons and components is 1:1 to avoid breaking changes within the talon affecting a related component that isn't quite identical to the original component.

So instead of reusing useFilterModal we should create a new talon called useFilterSidebar that is a duplicate of the other. You'll then want to put the sidebar-specific logic such as the handleApplyFilter callback creation within this new talon.

I appreciate your attempt at re-use here, and one day we might have a better example of generalized logic, but for now just create the unique talon please :)

Edit:

As a followup, I was curious if you attempted to try to reuse/rename FilterModal and just have a mobile view vs desktop view. I assume the differences warranted the new component, but still curious :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sirugh It hurts to duplicate that much code, but I'll do it for you ;). The state should hopefully cross over since it's essentially based off of the URL, but I'll test to be sure.

The work is slightly based off of one of our projects and their approach was to use the same component. However there were too many "if" conditions for it to be maintainable long term, so we went for the approach of having a separate component.

Copy link
Contributor

Choose a reason for hiding this comment

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

It hurts to duplicate that much code

I know :/ but the alternative is bug surface (for now). Eventually we will have a pattern for duplicated logic for talons, but we don't want to solve that here :)

packages/venia-ui/lib/components/SearchPage/searchPage.js Outdated Show resolved Hide resolved
sirugh
sirugh previously approved these changes May 12, 2021
Copy link
Contributor

@sirugh sirugh left a comment

Choose a reason for hiding this comment

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

Ok, good to go again.

@sirugh
Copy link
Contributor

sirugh commented May 14, 2021

@JustinConabreeAbsolunet do you have time to add test coverage to the new functionality? Looks like the CI is failing due to a ~1% drop in coverage. If you don't have time to do it we can get an internal developer to do it, so no worries - just let me know what works for you. Thanks!

@justinconabree
Copy link
Contributor Author

@sirugh Sure! I'll get that done today.

@justinconabree
Copy link
Contributor Author

@sirugh I copied over the useFilterModal test to the useFilterSidebar since the functionality is the same. And I added two new tests for the useFilterList and useFilterBlock. I think it's passing now. Let me know if you need more tests

@sirugh
Copy link
Contributor

sirugh commented May 17, 2021

Thanks Justin, we're almost there!

If you click the details link you can see what is causing the decrease. I think at a minimum we require 0% loss of coverage to files with tests, but I can't find our config...

@justinconabree
Copy link
Contributor Author

@sirugh yeah I saw right after posting the message. There was just enough delay for the coveralls test.
I'll implement some tests on the components then to get it to 0%!

@anthoula
Copy link
Contributor

anthoula commented May 19, 2021

@JustinConabreeAbsolunet Thanks Justin, I have this observation in Lighthouse. There is a new warning introduced Avoid an excessive DOM size. Is it possible to do some exploration to see if we can avoid this new warning?

Note: Refactored functional tests to accommodate mobile specific selectors, due to duplication in the DOM.

image

@justinconabree
Copy link
Contributor Author

Hi @anthoula ,

Unfortunately this is a byproduct of duplicating the dom of the layered nav for mobile and desktop. This is the same approach that was done with the mega-menu, and there's no good way to get around it while supporting SSR.

I'm open for suggestions, but this was the approach discussed with the PWA Studio team before we started the implementation, since there's nothing in place yet to handle different markup between desktop and mobile.

@anthoula
Copy link
Contributor

anthoula commented May 19, 2021

@JustinConabreeAbsolunet Second observation: Search for Tops, then click on the Price label for 100-200. Notice that on the first click, it does not select the filter, but on the second click of the label, it selects.

Related Observation: Search for Tops, then click on the Sort by ... button. Notice that on first click, the dropdown does not appear, but on the second click, the dropdown appears.

@justinconabree
Copy link
Contributor Author

@anthoula This seems to be caused by the search bar still being open and trapping the click elsewhere on the page. If you click elsewhere and then on the filter it works correctly.

This seems to have been the case prior to this PR as well
https://pr-3146.pwa-venia.com/
If you search for tops and try to click on the Filters button, nothing happens.

In my opinion it should be a separate issue, but I can work on it in this PR if you need.

@anthoula
Copy link
Contributor

Thanks for the contribution @JustinConabreeAbsolunet ! We will take a closer look at these items in a separate ticket.

@anthoula
Copy link
Contributor

QA approved

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.

[feature]: Desktop optimization for the layered navigation
7 participants