zooppa / administrate-field-simple_markdown

✍️ A plugin to edit Markdown text in Administrate
https://github.com/thoughtbot/administrate
MIT License
8 stars 13 forks source link

Many duplicate NestedHasMany elements get created when using Turbolinks #16

Closed sedubois closed 4 years ago

sedubois commented 4 years ago

Since using this gem, several instances of my NestedHasMany nested resources get created whenever clicking "Add Program/Translation".

See illustration before clicking (I removed the fields in the nested resource for conciseness):

Screenshot 2020-04-24 at 11 57 51

And after clicking:

Screenshot 2020-04-24 at 12 08 55

The number of duplicate boxes corresponds to the number of page navigations that have been performed by Turbolinks since the last full page load. E.g if I visit 2 other pages using my side navigation, then visit the Programs index, then click "New Program", then click "Add Program/Translation", then there will be 4 instances of the nested resource.

When commenting out turbolinks.start() in Javascript, the issue disappears.

NB: the issue is completely unrelated to whether there are actual Field::SimpleMarkdown used in dashboards. Just having the gem in the gemfile (and thus its Javascript loaded in the asset pipeline) is enough to get the issue.

It makes for a poor admin experience, but more importantly it also breaks the tests. Is there any way to make this gem work with Turbolinks?

Using administrate-field-simple_markdown 0.3.0, administrate-field-nested_has_many 1.2.0@bbc3cb777b.

michelegera commented 4 years ago

Hi @sedubois and once again apologies for the late response.

It seems clear to me that the feature to support interactions with NestedHasMany and/or Turbolinks is severely broken and since I don’t have bandwidth to dig into it and work on a fix, I’ve decided to revert the logic to HTML IDs and release a new version that at least ensures compatibility with basic scenarios.

Unfortunately I won’t be able to maintain this gem anymore, so if you or someone else wants to take over, I’d be happy to transfer the repository ownership.

I’m sorry for the hassle (and the wait!).

sedubois commented 4 years ago

Thank you @michelegera, understood. I am still considering migrating my markdown fields to ActionText, which would solve the issue. Thanks for all your work so far and all the best.