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

Having a Hyper field in a Matrix field creates constant "Showing your unsaved changes" message #189

Open
sjcallender opened this issue Aug 30, 2024 · 33 comments

Comments

@sjcallender
Copy link

sjcallender commented Aug 30, 2024

Describe the bug

Even with CRAFT_AUTOSAVE_DRAFTS=false, our Hyper fields within Matrix fields create drafts, but only when using Firefox (Mac). We can never escape the "Showing your unsaved changes" message.

Steps to reproduce

  1. Add a Hyper field to a Matrix field block and assign it an entry type of your choice.
  2. In Firefox, visit an entry where you can add content to the Hyper field, save it.
  3. Refresh and note the "Showing your unsaved changes" message.
  4. Click "Discard" and note the "Showing your unsaved changes" message reappears.

Craft CMS version

6.3.5

Plugin version

2.0.4

Multi-site?

No

Additional context

CleanShot 2024-08-30 at 10 52 49

@engram-design
Copy link
Member

I can't seem to replicate this in any browser I'm afraid, and I've replicated your field setup of nested Matrix fields. Certainly seems like a race condition based on the loading "flash" when you reload the page.

@stereomyth
Copy link

This has also happened to me in Chrome with a sufficiently complicated Neo field containing or next to a Hyper field. It stops happening if I disable the timeout added to updateInitialSerializedValue to fix Vizy compatibility. It does seem like a race condition during initialisation of different JS enhanced fields.

@sjcallender
Copy link
Author

Good find, @stereomyth.

@engram-design, would allowing us to set the timeout value for updateInitialSerializedValue be a reasonable option? Maybe we need to set ours at 1000, for example.

@engram-design
Copy link
Member

engram-design commented Sep 4, 2024

Just pushing some revised changes to address this. To get this early, run composer require verbb/hyper:"dev-craft-5 as 2.0.4". I'd love to see if that rectifies this.

@daveguillory
Copy link

Just pushing some revised changes to address this. To get this early, run composer require verbb/hyper:"dev-craft-5 as 2.0.4". I'd love to see if that rectifies this.

@engram-design I went ahead and updated to this on a local dev site, and I'm still getting the issue. It happens immediately after the page reloads from saving.

image

@engram-design
Copy link
Member

Thanks for letting me know @daveguillory. Sorry to be a pain, but can you replicate this with as minimal example as possible? Ideally with just the Hyper field, and maybe even disabling every other non-critical plugin. I'm struggling to reproduce these even after manually adding unrealistic timeout values to simulate race conditions.

@elfacht
Copy link

elfacht commented Sep 11, 2024

I am having the same issue with nested fields in Neo and it happens as soon I am entering an entry without any actions. Unfortunately the dev release doesn't fix it.

@elfacht
Copy link

elfacht commented Sep 11, 2024

Maybe this helps: we are running Craft 5.2.10 on production and are not facing this issue, but on the test system with Craft 5.4.2. In the meantime something may have changed in Craft causing this?

In 5.3.0 these changes came up:

  • Front-end queue runner scripts are now injected before the tag, rather than at the end of the response HTML.

Maybe this could cause the race condition?

@smockensturm
Copy link

Same exact issue. Extremely annoying behavior.

@DavidKabelitz
Copy link

Will this be fixed somehow? We also have it for some time and it's very annoying for the content editors.

@engram-design
Copy link
Member

Still trying to replicate this one, it's bizarre that everyone seems to be getting this but me! Working on it ASAP.

@elfacht
Copy link

elfacht commented Sep 21, 2024

@engram-design Have you tried you replicate it with tabbed field layouts? I see it in the example of @sjcallender and I'm having multiple tabs as well where this behaviour occurs.

@DavidKabelitz
Copy link

Still trying to replicate this one, it's bizarre that everyone seems to be getting this but me! Working on it ASAP.

I also have no issue with sharing my project config or veen whole project it that helps.

Looks like it’s only at a nested situation. So hyper field part of an entry, no problem at all. Hyper field as a child of e.g two neo fields is a problem.

@smockensturm
Copy link

More possible clues:

  • command-S (saving the entry without leaving the page) IMMEDIATELY refreshes the blue bits displaying "showing your unsaved changes"
  • discarding changes via the blue button IMMEDIATELY refreshes the blue bits displaying "showing your unsaved changes"
  • saving the entry via pushing the Save button (thus leaving the page) seems to calm things down for a minute

Confirming also this is a nested hyper field.

@engram-design
Copy link
Member

engram-design commented Sep 24, 2024

So I believe I can replicate this in some specific circumstances. Looking into options to address this. I've got a solution that's a combination of Hyper changes and a Craft change, so just working on a suitable PR to Craft for this.

@engram-design
Copy link
Member

Following up in craftcms/cms#15794

@smockensturm
Copy link

@engram-design hey thanks for your efforts, but this is affecting sibling fields (a CKEditor field for example) within an entry.

I don't think Hyper is a good choice for us if its mere presence is causing ElementEditor.js to wig out across the entry.

@engram-design
Copy link
Member

So this should be fixed in Craft 5.5 and Hyper 2.1. I'm surprised that's showing it on a sibling field, I'll take a look.

@smockensturm
Copy link

I'll try and explain.

The sibling field is a CKEditor field with a few nested entries options.

The sibling Hyper field(s) allow for multiple links.

When multiple links are configured in a sibling Hyper field, the CKEditor field cannot and will not allow one to add nested entries.

When a SINGLE link is configured in the same Hyper field, the CKEditor WILL allow one to add nested entries.

@engram-design
Copy link
Member

Thanks for the explanation, although it sounds like a different issue to the original draft-creation and showing unsaved changes one?

@DavidKabelitz
Copy link

@engram-design yes it's a different issue. The original issue is nested neo fields and inside those nested ones is a hyper field (single).

@smockensturm
Copy link

@engram-design Yeah it's a different issue! We've ditched Hyper and moved on though. Thanks.

@engram-design
Copy link
Member

@smockensturm No problem, thanks for the heads up about it, I'll investigate further.

@engram-design
Copy link
Member

Fixed in 2.1.0, but will need to wait for Craft 5.5 to be released, where they have added their fix.

@bymayo
Copy link

bymayo commented Nov 13, 2024

I can confirm this is now working with Craft 5.5 🎉

@elfacht
Copy link

elfacht commented Nov 13, 2024

I can confirm that I still have this issue in Craft 5.5.

Discarding the changes doesn't help either.

@DavidKabelitz
Copy link

Me too, still have it at 5.5

@engram-design
Copy link
Member

@elfacht @DavidKabelitz Going to assume you're also on Hyper 2.1.0. Cleared all the caches? I'm not able to reproduce it on my end. Are we talking multiple levels of Matrix blocks, or just one?

@elfacht
Copy link

elfacht commented Nov 15, 2024

@engram-design

I just saw that the plugin is still set to the dev version as I tried the fix:

"verbb/hyper": "dev-craft-5 as 2.0.4",

I did oversee it to update the plugin. I will update the plugin as soon as I'm back to work on monday …

Are we talking multiple levels of Matrix blocks, or just one?

In fact it's in nested Neo blocks where this happens.

@JeroenJRP
Copy link
Contributor

@engram-design I'm also having this issue with Craft 5.5 and Hyper 2.1.2, I can consistently reproduce it with 1 matrix block containing the hyper field which in turn contains your Icon Picker field. It also happens with an Entries field, but sometimes I need to switch tabs within the entry to trigger the problem.

firefox_2024-11-15_09-26-57.mp4
firefox_2024-11-15_09-23-45.mp4

@DavidKabelitz
Copy link

Hej Josh, @engram-design yes still there at 2.1.2, also deleted cache. It's fixed at another project but still appears at one i am working on. The interesting part and maybe its important. In this case it appears just after changing tabs how @JeroenJRP described. In our case 2 times nested NEO field. First tab active all good (main content we edit on second tab), after change of the tab we see the message again.

@martinleveille
Copy link

We also have the same issue when Hyper is in a Neo block. Latest version of everything.

@elfacht
Copy link

elfacht commented Nov 18, 2024

I just updated Hyper to 2.2.0 and this seems to fix the problem of the initial unsaved changes when entering an entry, but switching the tabs will cause the unsaved changes again.

Screen.shot.2024-11-18.um.08.56.33.mov

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

10 participants