verbb / hyper

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

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

Open sjcallender opened 2 weeks ago

sjcallender commented 2 weeks 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 weeks 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 weeks 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 1 week 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 1 week 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 1 week 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 1 week 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 6 days 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 6 days 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?