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

Matrix in Hyper #184

Open
stevendierick opened this issue Aug 14, 2024 · 5 comments
Open

Matrix in Hyper #184

stevendierick opened this issue Aug 14, 2024 · 5 comments

Comments

@stevendierick
Copy link

Describe the bug

A Matrix field in Hyper only works when the Matrix field's view mode is set to As inline-editable blocks. When the view mode is set to either As cards or As an element index it will throw invalid owner errors.

Steps to reproduce

  1. Create a Hyper field
  2. Create a Matrix field
  3. Set view mode of the Matrix field to As cards or As en element index
  4. Add the Matrix field to the Hyper field (under the content or advanced tab)
  5. Add a link to your Hyper field
  6. Add an entry to your Matrix field

Craft CMS version

5.3.4

Plugin version

2.0.4

Multi-site?

Yes

Additional context

No response

@engram-design
Copy link
Member

This is correct and unavoidable behaviour for now in Craft 5. This is because non-inline-blocks mode requires the parent owner to be a saved element. Hyper does not use elements for its content to increase performance, particularly for nested content.

I'm looking into alternatives, but right now it would require some PRs to Craft just to suit Hyper, which they may or may not be open to as it's niche and goes against the "everything is an element" approach.

@stevendierick
Copy link
Author

I might have encountered another Matrix issue within Hyper. I can't seem to replicate it elsewhere.

It's the same scenario as the original issue, even within the same project. We are using the same Matrix field in Hyper, and we went for inline-editable blocks as you suggested, but we're seeing Axios errors. However, on local development, the functionality still seems to work. On our staging/production environment, though, it doesn't trigger and just times out.

If we start fresh, no errors appear, but the functionality still doesn't work. It continues to work locally, but once you go deeper, Axios errors start showing up.

We have different types of navigations: Hyper-only, Hyper within Matrix, and Matrix within Hyper. The issues are only happening with the Matrix within Hyper setup.

Local example 1: https://share.cleanshot.com/d1pDN6t8fhxvRVb5CxJT
Local example 2: https://share.cleanshot.com/jXYxTN5V54C31Grfmrbr

Staging example 1: https://share.cleanshot.com/HRzY5K1gW9BTJsGjxCBy
Staging example 2: https://share.cleanshot.com/H0JWY7PqTvq0hXMbWTW5

Any idea what's going on?

Craft CMS version: 5.4.4
Plugin version: 2.0.5
Multi-site? Yes

@engram-design
Copy link
Member

Thanks for those videos. Can you check out the Network requests associated with those (in the Network tab of dev tools) and look at the Preview of those failed requests (the ones in red)? It's showing lots of 400 errors, but keen to know what the returned data is for those requests. It's also tricky to see exactly what requests are failing as the request name is cutoff.

@stevendierick
Copy link
Author

Ah of course, my bad!

  1. Local example 1, updating an existing navigation. Errors triggered on load and when going deeper with Matrix:
    https://share.cleanshot.com/2XRGMkpZ4Cyk5tk3VzpV

  2. Local example 2, starting fresh. Everything works but the error is only triggered when going deeper with Matrix:
    https://share.cleanshot.com/1g828jrpD6y39cxgGwwj

  3. Staging example 1, trying to update an existing navigation. Errors triggered on load, can't go any deeper with Matrix:
    https://share.cleanshot.com/Yts6K4dFn94X9Rf52cyY

  4. Staging example 2, starting fresh. Not working and no errors when trying to use the Matrix field:
    https://share.cleanshot.com/NHqtdKJPGvw1KC9Bplby

@engram-design
Copy link
Member

Thanks for the videos, that's very helpful!

So it seems it's due to our handling of Hyper in a Matrix field for Craft 5. Because of the Matrix/Entry changes and the different layouts, it's change Matrix's behaviour quite considerably. In this instance, it always expects the owner of a Matrix field to have an element, but as Hyper doesn't use elements for performance, we've had to skirt around things. It's the reason why we're limited to As inline-editable blocks for Matrix, as that uses an endpoint we can control to accommodate Hyper.

Having said that, I'd say this is due to the Hyper > Matrix > Hyper scenario you've got going on here. I'm investigating what's involved here, but it's a tricky situation with how Matrix fields work. It relies on have a saved owner element to even render.

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

No branches or pull requests

2 participants