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

Algolia hooks: update and patch #700

Merged
merged 20 commits into from
Sep 26, 2022
Merged

Conversation

danielbeardsley
Copy link
Member

@danielbeardsley danielbeardsley commented Sep 13, 2022

We have an open pull to make a change in the algolia react-instantsearch repo, but they
likely won't merge it. Since we need this diff to build with the newest version
of the hooks on vercel, let's use pnpm's patch utility to apply the change for now.

When we upgrade to React 18 we just need to drop the .js in the import
statement.

This was made using pnpm's built-in patch commands. Note: pnpm patch
just hung on pnpm v6, so I updated to v7. Seems there were some problems in the past... but they seem to be fixed now?

This also upgrades husky to v8 cause v4 wasn't compatible with pnpm 7

Closes #660

federicobadini and others added 5 commits September 9, 2022 16:19
We have an open pull to make a change in this algolia repo, but they
likely won't merge it. Since we need this diff to build on vercel, let's
just include it directly.

When we upgrade to React 18 we just need to drop the `.js` in the import
statement.

This was made using pnpm's built-in patch commands. Note: `pnpm patch`
just hung on pnpm v6, so I updated to v7, ran the commands, then
downgraded back to v6.
"pnpm patch" is only available in pnpm 7. Let's give it another try.
husky 4 wasn't compatible with pnpm 7, go figure...

Also, allow unmet peer dependencies (this defaults to true for pnpm 7,
so we switch it to true to maintain behavior)
@vercel
Copy link

vercel bot commented Sep 13, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
react-commerce ✅ Ready (Inspect) Visit Preview Sep 24, 2022 at 0:50AM (UTC)
react-commerce-prod ✅ Ready (Inspect) Visit Preview Sep 24, 2022 at 0:50AM (UTC)

package.json Outdated Show resolved Hide resolved
@sterlinghirsh
Copy link
Member

CR ⚡ dev_block ⚡ on pinning the husky version, though I'd like it if @federicobadini and/or @dhmacs took a look and made sure this looks reasonable to you too.

Copy link
Member

@sterlinghirsh sterlinghirsh left a comment

Choose a reason for hiding this comment

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

Oh I meant to request changes instead of approve.

@danielbeardsley
Copy link
Member Author

un_dev_block 👍

Copy link
Contributor

@masonmcelvain masonmcelvain left a comment

Choose a reason for hiding this comment

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

CR ✌🏻 Cool! I'll let @federicobadini or @dhmacs approve like @sterlinghirsh suggested

Copy link
Contributor

@federicobadini federicobadini left a comment

Choose a reason for hiding this comment

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

It seems that there is something that needs to be handled differently regarding navigation/reconciliation of the search state.

When we navigate from a filtered collection to a supposedly unfiltered collection we end up with the previously selected filters active.
Here is a video showing the problem:

Screen.Recording.2022-09-15.at.08.45.19.mov

frontend/package.json Outdated Show resolved Hide resolved
@masonmcelvain
Copy link
Contributor

This might be unrelated to what @federicobadini discovered, but this is another workaround we added for the url on the first render.

} else if (renderCount === 1 && itemTypeHandle) {
// Prevents a bug when visiting /Parts/iPhone/Cables
// that it would redirect to /Parts/iPhone
path += `/${itemTypeHandle}`;

I wonder if we can drop this else if clause now that we've upgraded.

@federicobadini
Copy link
Contributor

This might be unrelated to what @federicobadini discovered, but this is another workaround we added for the url on the first render.

} else if (renderCount === 1 && itemTypeHandle) {
// Prevents a bug when visiting /Parts/iPhone/Cables
// that it would redirect to /Parts/iPhone
path += `/${itemTypeHandle}`;

I wonder if we can drop this else if clause now that we've upgraded.

I did a quick test before and it seemed not present anymore but I have not covered all the possible test cases yet (first render / client side transition / back button navigation etc). I just tried to open the link in the comment.
Definitely it would be good to clean up that part if not needed anymore

@danielbeardsley
Copy link
Member Author

I updated the version but I don't have to time to dive deeper right now. Anyone else is welcome to pick this up.

…-and-patch

Conflicts:
   pnpm-lock.yaml
      * Lots of conflicts, but our branch and more significant changes
        (and a version bump of the format). So I kept our version
Master had added one dep since we diverged, so I kept our version of the
lock file then did `pnpm install` to ensure it was up to date with with
package.json requirements.
@danielbeardsley
Copy link
Member Author

Fixed the conflicts.

We validated that qsModule.parse() already does url decoding and we
don't need to re-do it on the return values.

Also, drop some defaults on destructuring because they already happen in
the code below.
This was added a bit ago because the server side state for algolia
wasn't matching up (or wasn't available).

See: a5481b5

This concern has been addressed and this code is now *causing* a
serverside / clientside state mismatch and react is complaining that the
two states don't match. Removing this and depending on algolias
knowledge of the refinements produces relaible results.
corepack was saying it can't find any version compatible with '7'

I still don't understand why corepack helps us here, so I'm reverting
to plain 'npm install' which is simpler and actually let's us install
the latest version.
@danielbeardsley
Copy link
Member Author

Ok, @masonmcelvain and I have addressed the issues he brought up, so I think we are good.

un_dev_block 👍

This field is unused as of 4ec07e2, so let's drop it to prevent accidental usage in the future.
@sterlinghirsh
Copy link
Member

CR ⚡ dev_block ⚡ on what looks like relevant test failures. I think we put the deviceItemType stuff in the findProductList function in part to make sure that the canonical on item type pages included that. It's possible that didn't work before because of the Algolia bugs fixed by the new hooks version. I don't remember if we added a test for canonicals on item type pages, but it's worth a check.

@danielbeardsley
Copy link
Member Author

I think the failures were a quirk of having installed pnpm through both corepack and npm. Notice it only failed on one of them. Either way, I think we don't need to dev block on a CI failure (the CI failure already blocks).

un_dev_block 👍 I've re-run the failed build.

Previous one was failing for some mysterious reasons.
Copy link
Contributor

@masonmcelvain masonmcelvain left a comment

Choose a reason for hiding this comment

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

CR ✌🏻

@erinemay erinemay self-assigned this Sep 26, 2022
@erinemay erinemay added the QAing Under QA team review label Sep 26, 2022
@erinemay
Copy link
Contributor

QA 🎦

  • Applying multiple filters and moving down the tree with model buttons and moving up the tree with the breadcrumbs. No filters were preserved with upward or downward navigation (both filters and item type facets)
  • Using the back button with filters, item type facets, search. Back button still worked as expected.
  • Using the back button to navigate back to a page with multiple filters (all were present)
  • Entering a page directly (refreshing) with and without facets
  • Checked with prod preview next to ifixit.com/Parts and confirmed the same above filter behavior on both
  • Search results and behavior when entering or deleting text is identical between prod-preview and ifixit.com (checked various search terms with identical filters)
  • Everything in Algolia hooks: update and patch #700 (comment) is the same
  • Can't reproduce Algolia hooks: update and patch #700 (review)
  • Can't reproduce Algolia hooks: update and patch #700 (comment)
  • Can't reproduce Algolia hooks: update and patch #700 (review)

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.

Update React Instantsearch dependency
7 participants