verbb / hyper

A Craft CMS plugin for managing links, focusing on user experience.
Other
24 stars 15 forks source link

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

Open sjcallender opened 2 months ago

sjcallender commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

Same exact issue. Extremely annoying behavior.

DavidKabelitz commented 2 months ago

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

engram-design commented 2 months ago

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

elfacht commented 2 months ago

@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 commented 2 months ago

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 commented 2 months ago

More possible clues:

Confirming also this is a nested hyper field.

engram-design commented 2 months ago

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 commented 2 months ago

Following up in https://github.com/craftcms/cms/discussions/15794

smockensturm commented 2 months ago

@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 commented 2 months ago

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 commented 1 month ago

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 commented 1 month ago

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

DavidKabelitz commented 1 month ago

@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 commented 1 month ago

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

engram-design commented 1 month ago

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

engram-design commented 1 month ago

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

bymayo commented 1 week ago

I can confirm this is now working with Craft 5.5 πŸŽ‰

elfacht commented 1 week ago

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

Discarding the changes doesn't help either.

DavidKabelitz commented 1 week ago

Me too, still have it at 5.5

engram-design commented 1 week ago

@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 commented 1 week ago

@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 commented 1 week ago

@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.

https://github.com/user-attachments/assets/970f4916-54f7-4dab-8d19-3e268ef5110f

https://github.com/user-attachments/assets/e2a783bb-c46e-4678-9bfc-730b34e0b235

DavidKabelitz commented 1 week ago

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 commented 1 week ago

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

elfacht commented 1 week ago

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.

https://github.com/user-attachments/assets/258b031b-0139-4fcd-9ac7-66cafd4dddbf

niektenhoopen commented 1 week ago

I can confirm this is now working with Craft 5.5 πŸŽ‰

@bymayo Can you please elaborate how you tested this? Switching tabs still gives me the same issue.

I am having the same issue as @JeroenJRP and @elfacht

engram-design commented 1 week ago

I can certainly replicate the changing-tab behaviour. Fixed for the next release. To get this early, run composer require verbb/hyper:"dev-craft-5 as 2.2.0".

idleog commented 2 days ago

I have the same problem, I am now on dev-craft-5 as 2.2.0 and CraftCMS 5.5.3, On entries which were ok before, it now does not happen anymore. But on entries having this problem before updating hyper, the problem still exists.

engram-design commented 11 hours ago

@idleog Can you let me know your field setup, and ideally a video of this happening? Be sure to discard any changes to ensure you're starting fresh.

idleog commented 4 hours ago

The video is here: https://www.dropbox.com/s/e4f6wps4khcc0e9/video_craft.mov?e=1&dl=0

setup of field: I think you can see it in the video (hyper in matrix block), If I understnd you right. Else let me know what you need!